How to get any http session by id or all currently active http sessions within web application (Java 2 EE) in an elegant way?
Currently I have a WebSessionListener
and once session was created I put it in ConcurrentHashMap() (map.put(sessionId, sessionObj))
, everything ok, I can retrieve HTTP session from that map in any time by session id, but it looks like the HttpSession
objects will never finalize... Even session was invalidated the map still reference on invalidated session object... Also I have read this article and it looks like the WeakHashMap
is not acceptable in my case...
In other words I need a possiblity to look in any HttpSession even get all currently active HttpSession
and retrieve some attributes from there...
Please advice somebody :)