Three ways to set session validity time in JSP

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.