Tuesday, September 19, 2017

Tomcat: Application session timeout


To set the session timeout for the Tomcat web application, call HttpSession.setMaxInactiveInterval(int interval) -- interval is the idle time in seconds before timeout. e.g. HttpSession.setMaxInactiveInterval(30) times out the session if it is idle more than 30 seconds.

If the above method is not call in the application, the session-timeout configuration in the application's web.xml defines the timeout in minutes. e.g. WEB-INF/web.xml:
    <session-config>
          <session-timeout>1</session-timeout>
    </session-config>
The above configuration times out the session after 1 minute.

If the session-timeout is not set in the application's web.xml, it is defined in TOMCAT_HOME/conf/web.xml:
    <session-config>
          <session-timeout>30</session-timeout>
    </session-config>

No comments:

 
Get This <