What is the default session timeout for a Java EE website?

情到浓时终转凉″ 提交于 2019-12-17 18:16:24

问题


If I do not specify the following in my web.xml file:

<session-config>
    <session-timeout>10</session-timeout>
</session-config>

What will be my default session timeout? (I am running Tomcat 6.0)


回答1:


If you're using Tomcat, it's 30 minutes. You can read more about it here.




回答2:


You can also set this in code, for a specific session using the HttpSession setMaxInactiveInterval API:

Specifies the time, in seconds, between client requests before the servlet container will invalidate this session. A negative time indicates the session should never timeout.

I mention this in case you see timeouts that are not 30 minutes, but you didn't specify another value (e.g. another developer on the project used this API).

Another item to note is this timeout may not trigger on the exact second the session is eligible to expire. The Java EE server may have a polling thread that checks for expired sessions every minute. I don't have a reference for this, but have seen this behavior in the WebSphere 5.1 era.




回答3:


I'm sure it depends on your container. Tomcat is 30 minutes.




回答4:


Session Time out we can specify for that particular context in web.xml file as mentined below entry 60

Default Session time out is 30 mins



来源:https://stackoverflow.com/questions/141734/what-is-the-default-session-timeout-for-a-java-ee-website

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!