(1) Add:
Httpsession session = request. getsession (true );
Session. setmaxinactiveinterval (900 );
The unit of the parameter 900 is seconds. That is, the session will expire after 15 minutes of no activity.
Note that the time set for this session is calculated based on the server, rather than the client. So if you are debuggingProgramIt should be to modify the server time for testing, not the client.
(2) It is also a common method to set the session expiration time, that is, to set the session expiration time in the project's web. xml.
<Session-config>
<Session-Timeout> 15 </session-Timeout>
</Session-config>
15 or 15 minutes are invalid.
(3) set it directly on the application server. If it is tomcat, you can set it in CONF/Web. xml under the Tomcat directory.
Find the <session-config> element. Tomcat is set to 30 minutes by default. You only need to modify this value.
It should be noted that if all three of the above are set, there is a priority problem, from high to low:
(1 )--? (2 )---? (3)
Reference: http://blog.csdn.net/xiaosu_521/article/details/2045757