The life cycle of the general session is established in the user log on the system after the user information to a record, session similar to you have a bank card, and the money is the memory of the session stored information, card out of the money can not be taken out.
The lifetime of the previous session was that the client did not interact with the server within 20 minutes and the session was destroyed; some servers now have a lifetime of 30 minutes. Session sessions are stored on the server side.
Here are the settings for several life cycles of the session:
One, the most brutal way to set up
Modify the value in <session-time-out></session-time-out> in the Web. xml file under the server's corresponding configuration file.
As shown in the following:
Tomcat default session timeout is 30 minutes, can be modified as needed, negative or 0 is not limit session failure time.
Second, commonly used is also a relatively simple method
Configure parameters in your project's Web. xml file:
The corresponding XML code is as follows:
<session-config>
<session-timeout>20</session-timeout>
</session-config>
The above 20 means that the duration of the session is 20 minutes. This is calculated in minutes.
Three, a more docile way of setting up
Add the following code in the main Page/public page/or in the code below the corresponding servlet:
Session.setmaxinactiveinterval (You want to set the time);
The time that is set is calculated in seconds, and it is calculated based on the server.
Note: The above priority is: three-two > A
Javaweb on several setting methods of Session life cycle