Reputation:
I'm using tomcat8 and I like to look through the available sessions and invalidate/alter some sessions in my servlet
Currently I keep every sessions in my own context(Vector) and I believe it's not a good idea.
So how may I access tomcat session management/context to do so?
Thanks
Upvotes: 4
Views: 2089
Reputation: 20837
You can use JMX to look into Tomcat's internals, including the current list of sessions. Use jvisualvm
to connect to a running Tomcat and look-around for the interesting data.
Then use the JMX API to connect to the (in-process) JMX server from your application and find the (Session) Manager
bean to get everything.
Upvotes: 0
Reputation: 34424
I think your looking for HttpSessionListener
.You can hold of sessions all with help of this. Thats the most cleaner way i can think of.
See below examples
How to easily implement "who is online" in Grails or Java Application?
How can i load Java HttpSession from JSESSIONID?
Upvotes: 3