August 2, 2009

Servlets: A note on HttpSession Timeout

Setting Session Timeout Programmatically:

HttpSession session = request.getSession();
session.setMaxInactiveInterval(15 * 60); // timeout in seconds
// –1: session never expires, 0: session times out immediately 

Setting Session Timeout Declaratively/Configuratively:

In the web.xml:

<web-app ...>
...
   <session-config>
      <session-timeout>15<session-timeout> <!—Timeout in minutes -->
   </session-config>
</web-app>

2 comments:

  1. Session timeout is not termitated.

    ReplyDelete
  2. Its the session object/s that get terminated as per the timeout period. There is nothing like Session timeout being terminated.

    ReplyDelete