Issue
What does tomcat do when session expires?
Does it set the session object invalidated?
Does it unlink all references to the session object so that I may not be able to get the expired session object by calling request.getSession(false)
?
I'm using Servlet 2.5 spec. Thanks.
Solution
There is no internal session garbage collector thread. Session are removed during getSession()
invocations.
If request.getSession()
is invoked and the session is no longer valid (its idle time is greater than maxInactiveInterval
) then internal expire()
method will be called. This method removes session from the Manager
and fires appropriate events on the HttpSessionListener
.
One can manually invalidate the session using its invalidate()
method, which is a wrapper for the expire()
.
Answered By - Tomek Rękawek
Answer Checked By - David Goodson (JavaFixing Volunteer)