How to set session timeout dynamically in Java web applications?

后端 未结 4 2270
慢半拍i
慢半拍i 2020-11-30 23:50

I need to give my user a web interface to change the session timeout interval. So, different installations of the web application would be able to have different timeouts fo

4条回答
  •  再見小時候
    2020-11-30 23:53

    Is there a way to set the session timeout programatically

    There are basically three ways to set the session timeout value:

    • by using the session-timeout in the standard web.xml file ~or~
    • in the absence of this element, by getting the server's default session-timeout value (and thus configuring it at the server level) ~or~
    • programmatically by using the HttpSession. setMaxInactiveInterval(int seconds) method in your Servlet or JSP.

    But note that the later option sets the timeout value for the current session, this is not a global setting.

提交回复
热议问题