Re: How to track the valid session number in the container

Michael Weller <[email protected]>
Newsgroups gmane.comp.java.sun.servlet
Message-ID <007f01c2d7f9$dc73f290$2207b9d9@gutschimachine>
> I would like to know how many active valid sessions
> currently running in the container, ie how many users
> are using the system at the snapshot. How can I
> approache it? Thanks

There's no direct way to get this number (i.e no method in ServletContext,
etc. that gives you that number directly).
However, you can add a HttpSessionListener to your app and let it change
(sessionCreated increments the number, sessionDestroyed decrements it) a
number saved as an attribute in the servlet context. To get to current
number just get that attribute from the context.

HTH!

-mw

___________________________________________________________________________
To unsubscribe, send email to [email protected] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.