File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes How do you get all sessions? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "How do you get all sessions?" Watch "How do you get all sessions?" New topic
Author

How do you get all sessions?

K Riaz
Ranch Hand

Joined: Jan 08, 2005
Posts: 375
Does the Servlet API allow you to retrieve all active sessions? I need to iterate through each one, looking for a particular attribute in the session and then invalidate the session.

I see that HttpSessionContext existed for some time before being removed. Any alternatives?

Thanks.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

One alternative is to use a session listener and a context scoped map to store references to all the sessions.

There was a fairly detailed thread on this a while back.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
For security reasons you're not allowed to snoop through other sessions.


42
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Here:

http://www.coderanch.com/t/360149/Servlets/java/know-which-users-system
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How do you get all sessions?