It's not a secret anymore!
The moose likes Tomcat and the fly likes Enumerate active sessions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Enumerate active sessions" Watch "Enumerate active sessions" New topic

Enumerate active sessions

Nicola Cisternino

Joined: Oct 19, 2011
Posts: 3
Hi all,
How can I enumerate Active Sessions in my application so as in Tomcat 7 manager app ?
I've just tried to trace session creation/destruction using a custom SessionListener ... but I'm sure that can be used the Tomcat internal structure to retrieve the sessions reference.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63867

I would highly recommend against using a container-specific solution.

[Asking smart questions] [About Bear] [Books by Bear]
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17421

For a general-purpose webapp, the best bet is to hook a session listener into a central monitoring point. Which could be as simple as an application-scope bean containing a hashtable.

For a webapp specifically intended to control Tomcat and only Tomcat, you should look at the Tomcat JMX/MEJB properties to see what's offered.

Only as a last resort should you hook into internal Tomcat code. Anything that dependent on the kitty's innards is probably going to require extensive rework every time Tomcat goes into a new major release.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: Enumerate active sessions
It's not a secret anymore!