session设置超时的问题

1. 在web.xml中定义:
<web-app>
<!--filter.listener,servlet,and servlet-mapping等元素要在session-config之前-->
    <session-config>
         <session-timeout>20 </session-timeout>
    </session-config>
</web-app>
  时间单位为分钟

2. 在tomcat->conf->servler.xml文件中定义:

       <Context path="/test" docBase="/test" 
     defaultSessionTimeOut="3600" isWARExpanded="true" 
     isWARValidated="false" isInvokerEnabled="true" 
     isWorkDirPersistent="false"/>
       defaultSessionTimeOut="3600"

3.WEBLOGIC的控制台设定。WEB-INF->weblogic.xml中,格式如下:
<session-descriptor>
    <session-param>
      <param-name>TimeoutSecs</param-name>
      <param-value>7200</param-value>
    </session-param>
</session-descriptor>
param-value中的数值就是超时时间,单位为秒。

3. 在程序中定义:
session.setMaxInactiveInterval(30*60);
设置单位为秒,设置为-1永不过期

你可能感兴趣的:(tomcat,xml,Web,servlet,weblogic)