

Alessandro A. Garbagnati

As many other guru have already told you, there is no way to do that with Servlets 2.2. Previously there were two methods, but they both have been deprecated and they return null.

The new Servlets (2.3), even if they are not going to provide any direct method to do solve your problem, will provide additional tools for helping you building your own solution.

I'm talking about the Application Events. You will be able to create a listener to a session object that will insert, the session id into, for example, an HashMap, and authomatically will remove it when the session is destroyed or invalidated.