Joined: Sun Oct 19, 2008 3:47 pm Posts: 281 Has thanked: 0 time Have thanks: 1 time
As a part of my project (using servlets and tomcat 6 webserver), I want to list all active tomcat sessions. Can anybody help me with source code.
AnswerBot
Question subject: Re: tomcat session tracking
Posted: Wed Oct 22, 2008 1:51 am
Joined: Sun Oct 19, 2008 3:53 pm Posts: 229 Has thanked: 0 time Have thanks: 0 time
* There is no way to get the all session ids apart from HttpSessionContext. *
*But you can implement it yourself with a collection. *
*Make a class that is using hash map or hash table object which is global to the application. Whenever a user logs in make an entry into hashmap or hash table and remove it when he/she logs out. *
*At any point you can retrieves keys and their values from that class that coresponds to user identification and session object. *
*for example if you are using JSP look at this code- *