Java – Changing the default session timeout of a spring web application

javasession-timeoutspringtomcat

I have to test a web application that is written by spring and jsp. The default session-timeout for the application is 30 min.

I want to reduce the session-timeout. For doing this, I have changed in the web.xml file in tomcatInstallationLocation/conf/. But it doesn't work. The default configuration in tomcatInstallationLocation/conf/web.xml was –

<session-config>
    <session-timeout>30</session-timeout>
</session-config>

Where I've just changed the time and make it –

<session-config>
    <session-timeout>5</session-timeout>
</session-config>

But is still doesn't work. As I know far, in this situation I have to make a change in my spring application's web.xml. But I'm not sure. Can any one help me?

Thanks in advance.

Best Answer

Session timeout hierarchy:

  • $tomcat_home/conf/web.xml
  • $your_webapp/WEB-INF/web.xml
  • manual invocation of HttpSession.setMaxInactiveInterval(int)

Each subsequent entry overrides others above.