简体   繁体   English

Servlet应用程序:Http会话超时

[英]Servlet application: Http session timeout

Hi just want to confirm when a session is expired in a webapp based on servlet. 嗨,您只是想确认基于servlet的webapp中的会话何时过期。 The following session id will be available until the session is garbage collected, is that correct? 在会话被垃圾回收之前,以下会话ID才可用,对吗? httpServletRequest.getRequestedSessionId() httpServletRequest.getRequestedSessionId()

Thanks, C 谢谢,C

When a session is expired getRequestedSessionId() return id new session which will be created when you call this method 当会话过期时,getRequestedSessionId()返回ID新会话,该新会话将在您调用此方法时创建

To check if session is timed-out (in invalid state) check isRequestedSessionIdValid 要检查会话是否超时(处于无效状态),请检查isRequestedSessionIdValid

if the session got expired, then at that point the session will be garbage collected and 如果会话过期,那么届时将对该会话进行垃圾收集,

httpServletRequest.getRequestedSessionId() will return new value when that method is called. 调用该方法时,httpServletRequest.getRequestedSessionId()将返回新值。

please check below url 请检查以下网址

http://download.oracle.com/docs/cd/E17802_01/products/products/servlet/2.1/api/javax.servlet.http.HttpServletRequest.html#getRequestedSessionId%28%29 http://download.oracle.com/docs/cd/E17802_01/products/products/servlet/2.1/api/javax.servlet.http.HttpServletRequest.html#getRequestedSessionId%28%29

From JavaDoc JavaDoc

  • getRequestedSessionId getRequestedSessionId

    public abstract String getRequestedSessionId() 公共抽象字符串getRequestedSessionId()

    Gets the session id specified with this request. 获取与此请求指定的会话ID。 This may differ from the actual session id. 这可能与实际的会话ID不同。 For example, if the request specified an id for an invalid session, then this will get a new session with a new id. 例如,如果请求为无效会话指定了ID,则这将获得一个具有新ID的新会话。

    Returns: the session id specified by this request, or null if the request did not specify a session id 返回:此请求指定的会话ID;如果请求未指定会话ID,则返回null

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM