user  

Setting Session setMaxInactiveInterval

CRANFORD, CHRIS
Thu, 19 Nov 2009 07:16:38 -0800

What is the proper way in Struts2 to dynamically set a particular
application's session timeout value (HttpSession setMaxInactiveInterval)
during the login process so that the session properly expires?  

Is this only possible by creating an HttpSessionListener and putting it
in web.xml?

public class MyAppSessionListener implements HttpSessionListener 
{
  public void sessionCreated(HttpSessionEvent event) {
    HttpSession session = event.getSession();
    session.setMaxInactiveInterval(60*5);
  }
  public void sessionDestroyed(HttpSessionEvent event) {
    HttpSession session = event.getSession();
    Session.invalidate();
  }
}

<listener>
  <listener-class>MyAppSessionListener</listener-class>
</listener>

Thanks,
Chris



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

  • Setting Session setMaxInactiveInterval CRANFORD, CHRIS