Java EE 网站的默认会话超时是多少?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/141734/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 08:50:28  来源:igfitidea点击:

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

javajsptomcatjakarta-ee

提问by karlgrz

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

如果我没有在 web.xml 文件中指定以下内容:

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

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

我的默认会话超时时间是多少?(我正在运行 Tomcat 6.0)

采纳答案by Huuuze

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

如果您使用的是 Tomcat,则为 30 分钟。您可以在此处阅读更多相关信息。

回答by JavadocMD

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

我确定这取决于您的容器。Tomcat 是 30 分钟。

回答by Kevin Hakanson

You can also set this in code, for a specific session using the HttpSessionsetMaxInactiveIntervalAPI:

您还可以在代码中为使用HttpSessionsetMaxInactiveIntervalAPI的特定会话设置此项:

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.

指定 servlet 容器使此会话无效之前客户端请求之间的时间(以秒为单位)。负时间表示会话不应超时。

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).

如果您看到不是 30 分钟的超时,但您没有指定其他值(例如,项目中的另一个开发人员使用此 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.

另一个需要注意的事项是此超时可能不会在会话符合到期条件的那一刻触发。Java EE 服务器可能有一个轮询线程,每分钟检查一次过期的会话。我没有这方面的参考资料,但在 WebSphere 5.1 时代看到过这种行为。

回答by sharath

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

会话超时我们可以在 web.xml 文件中为该特定上下文指定,如下面的条目 60

Default Session time out is 30 mins

默认会话超时为 30 分钟