1) Timeout in the deployment descriptor (web.xml)
- sets the timeout value to "minute", encloses the "session-config" element.
Markup
<web-app ...> <session-config> <session-timeout>20</session-timeout> </session-config> </web-app>
The above parameter applies to the entire web application, and the session will be killed by the container if the client does not make a request after 20 minutes.
2) Timeout with setMaxInactiveInterval()
- You can manually specify the timeout value in seconds for a specific session.
Java
HttpSession session = request.getSession(); session.setMaxInactiveInterval(20*60);
The above parameter applies only to the session that calls the setMaxInactiveInterval () method, and the session will be killed by the container if the client does not complete any request after 20 minutes.
source share