Get session id for making invalidate the session

I thing this is the simple questions . any body please answer the following question . I am new to java servlet .. I want to know who are all the active users in the server . other words is it possible to know how many users currently login in the server ..

Message was edited by:

sat_hiya

Message was edited by:

sat_hiya

[354 byte] By [sat_hiyaa] at [2007-10-2 23:59:02]
# 1
You need to use HttpSessionListenerSee http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/http/HttpSessionListener.htmland an example of what you want to achive at http://www.stardeveloper.com/articles/display.html?article=2001112001&page=1
dapachecoa at 2007-7-14 16:46:10 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Use the HttpSessionActivationListener to catch when a session is created and invalidated.
tolmanka at 2007-7-14 16:46:10 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

> Use the HttpSessionActivationListener to catch when a

> session is created and invalidated.

I don't believe that this will have the desired effect.

From the JavaDocs

Objects that are bound to a session may listen to container events notifying them that sessions will be passivated and that session will be activated. A container that migrates session between VMs or persists sessions is required to notify all attributes bound to sessions implementing HttpSessionActivationListener.

This interface allows an object that is part of a session to listen to events relating to that session. Using this it would be possible to code a solution that maintains the count of the number of active users, but I believe that the better solution is to use HttpSessionListener

Implementations of this interface are notified of changes to the list of active sessions in a web application. To receive notification events, the implementation class must be configured in the deployment descriptor for the web application.

dapachecoa at 2007-7-14 16:46:10 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
You are right I picked the wrong listener.
tolmanka at 2007-7-14 16:46:10 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...