three ways to set session validity time in JSP
2010-08-03 10:02:49| Category: Java Web| Report | Font size Subscription
(1) on the main page or on the public page, add:
HttpSession session=request.getsession (TRUE);
Session.setmaxinactiveinterval (900);
The parameter 900 is in seconds, i.e. the session will expire after 15 minutes of inactivity.
It is important to note that the time set by this session is calculated on the server, not the client. So if you are debugging a program, you should modify the server-side time to test instead of the client.
(2) It is also a more general way to set the session expiration time, which is set in the Project Web. xml
<session-config>
<session-timeout>15</session-timeout>
</session-config>
The 15 here is 15 minutes of failure.
(3) Directly in the application server settings, if it is Tomcat, you can conf/web.xml in the Tomcat directory
To find the <session-config> element, the Tomcat default setting is 30 minutes, as long as you modify this value.
It should be noted that if the above three places are set, there is a priority problem, from high to Low:
(1)--? (2)---? (3)
This article from Csdn Blog, reproduced please indicate the source: http://blog.csdn.net/xiaosu_521/archive/2008/01/15/2045757.aspx
Three ways to set session validity time in JSP