Hi just want to confirm when a 开发者_如何学Gosession is expired in a webapp based on servlet. The following session id will be available until the session is garbage collected, is that correct? httpServletRequest.getRequestedSessionId()
Thanks, C
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.
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
When a session is expired getRequestedSessionId() return id new session which will be created when you call this method
To check if session is timed-out (in invalid state) check isRequestedSessionIdValid
From JavaDoc
getRequestedSessionId
public abstract String getRequestedSessionId()
Gets the session id specified with this request. This may differ from the actual session id. For example, if the request specified an id for an invalid session, then this will get a new session with a new id.
Returns: the session id specified by this request, or null if the request did not specify a session id
精彩评论