File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Accessing session of another user Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Accessing session of another user" Watch "Accessing session of another user" New topic

Accessing session of another user

sachin pathak

Joined: Jun 05, 2002
Posts: 27
I want to implement following functionality. I have an application where there can be number of users logged in at a time. Now we have a special user called as Admin. We need to provide a way for admin to logout the other users. We are storing the user authentication information in the session for every user. So one of the way is to get all the session objects and invalidate the ones which satisfy certain condition. How do I do this ?
In other words I want to get the HTTPSession objects for all the sessions currently maintained by the server.
Thanks in advance
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
Although the servlet API used to have more direct functions for this, they were removed due to security concerns.
You are going to have to "roll your own" by using the various session listeners. Exactly how depends on which servlet API your server implements.
See for example javax.servlet.http.HttpSessionListener - new with api 2.3
I agree. Here's the link:
subject: Accessing session of another user
jQuery in Action, 3rd edition