0

会话到期时tomcat会做什么?

它是否将会话对象设置为无效?

它是否取消了对会话对象的所有引用,以便我可能无法通过调用来获取过期的会话对象request.getSession(false)

我正在使用 Servlet 2.5 规范。谢谢。

4

2 回答 2

0

Tomcat (and every other container) will call HttpSession.invalidate()

From the documentation:

Invalidates this session then unbinds any objects bound to it.

Afterwards, request.getSession(false) will return null.

Related:

于 2013-10-01T09:21:47.383 回答
0

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

于 2013-10-01T09:24:02.673 回答