1. Set in the Web container (for example, Tomcat here)
Set in Tomcat-5.0.28\conf\web.xml, the following is the default configuration in Tomcat 5.0:
[HTML]View PlainCopy
- <!--==================== Default Session Configuration =================--
- <!--You can set the default session timeout (in minutes) for all newly--
- <!--created sessions by modifying the value below. -
- <session-config>
- <session-timeout>30</session-timeout>
- </session-config>
Tomcat default session timeout is 30 minutes, can be modified as needed, negative or 0 is not limit session failure time.
2. Set up in the project's Web. xml
[HTML]View PlainCopy
- <!--time in minutes--
<session-config>
<session-timeout>15</session-timeout>
</session-config>
3. Using Java Code settings
Session.setmaxinactiveinterval (30*60);//in seconds
Three ways of priority: 1 < 2 <3
Three ways to set session timeout (fail) in Java