开发者

Will session.invalidate() remove the attribute set to the session?

If开发者_开发技巧 I set the attribute value in the request and after that I call session.invalidate(), what will happen to attribute values? Will they be there still?


They will be still in memory, but they are not referenced by the HttpSession in question anymore. I.e. they are not accessible by HttpSession anymore.

Once the Garbage Collector runs and those objects do not have any other references by any other classes/instances, then they will ultimately be destroyed and free memory.


request and sessions are two different things. attributes set in request will be available until you serve the request. Once done all values will be vanished.

Attributes in session will be there until session gets expired or you call invalidate explicitly. Either of these will kill the current session and create a new one on next request onwards.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜