You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Michael Kuz <mk...@ServiceIntelligence.com> on 2001/01/06 17:24:49 UTC

acive session count?

I need to get a count of the number of active sessions in an instance of
Tomcat.

Was hoping it could be a flag (Tomcat -getSessionCount) or the like, so I've
been looking at adding a getSessionCount() method from the StandardManager,
through to Tomcat... But I need to get the ContextManager for the running
instance. And that isn't stored as a static. 

Is this info available through other avenues? Any solutions/ Pointers in the
right direction?

Thanks,
mk


 

Re: acive session count?

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Michael Kuz wrote:

>
>
> I need to get a count of the number of active sessions in an instance of
> Tomcat.
>
> Was hoping it could be a flag (Tomcat -getSessionCount) or the like, so I've
> been looking at adding a getSessionCount() method from the StandardManager,
> through to Tomcat... But I need to get the ContextManager for the running
> instance. And that isn't stored as a static.
>
> Is this info available through other avenues? Any solutions/ Pointers in the
> right direction?
>

Well, anything that accesses Tomcat internals is going to be Tomcat-specific ...

You might consider one of the following approaches:

* Under Tomcat 3.2 (servlet 2.2 API), have your application always
  install an object of a particular class in the user's session when
  they log on.  Have this class implement HttpSessionBindingListener.
  Then, you can accumulate and maintain a list (or count, or whatever)
  of the active sessions.

* Under Tomcat 4.0 (servlet 2.3 API), implement an application events
  listener that hears about all session creations and destructions.  This
  works without even needing cooperation from other parts of your app
  to make sure they install an HttpSessionBindingListener object.

>
> Thanks,
> mk
>
>

Craig McClanahan


Re: acive session count?

Posted by cm...@yahoo.com.
> I need to get a count of the number of active sessions in an instance of
> Tomcat.
> 
> Was hoping it could be a flag (Tomcat -getSessionCount) or the like, so I've
> been looking at adding a getSessionCount() method from the StandardManager,
> through to Tomcat... But I need to get the ContextManager for the running
> instance. And that isn't stored as a static. 
> 
> Is this info available through other avenues? Any solutions/ Pointers in the
> right direction?

You can take a look at the /admin application - there is code to access
the Request and from there you can access the ContextManager, all
Interceptors, etc.

The mechanism for accessing Request is greatly enhanced in 3.3 ( and a
taglib is provided ), but 3.2 and 3.1 should work as well.

Costin