1) Timeout in the deployment descriptor (Web. xml)
In minutes
Code to copy code as follows
<web-app ...>
<session-config>
<session-timeout>20</session-timeout>
</session-config>
</web-app>
The above setting takes effect for the entire Web application. When the client does not initiate a request within 20 minutes, the container kills the session.
2) Timeout with Setmaxinactiveinterval ()
Specifies the expiration time, in seconds, for a specific session by encoding. For example:
Code to copy code as follows
HttpSession session = Request.getsession ();
Session.setmaxinactiveinterval (20*60);
The above setting is only apply on session which call the "Setm (www.111cn.net) Axinactiveinterval ()" method, and session WI ll be kill by container if client doesn ' t do any request after minutes.
Thoughts ....
This was a bit confusing, the value in Deployment Descriptor (Web. xml) is in "minute", but the Setmaxinactiveinterval () Me Thod is to accept the value in "second". Both functions should synchronize it in the future release
3) defined in the program, in seconds, set to 1 means never expires, the sample code is:
Code to copy code as follows
Session.setmaxinactiveinterval (30*60);
The priority of the session setting effect is, the first program after the configuration, the first local after the whole
From:http://www.111cn.net/jsp/java/59186.htm
Java settings How to configure the session expiration time