users@glassfish.java.net

Re: Getting list of all users currently logged in to webapp

From: <glassfish_at_javadesktop.org>
Date: Fri, 06 Jun 2008 08:57:32 PDT

This is something that really the web-app should implement in a portable way, so I don't think GlassFish can provide you something "special".

One way to implement this could be to implement the HttpSessionListener that gets notified when
the web container creates a "session". Now, it is obvious that a session does not necessarily mean
a distinct user (or more correctly an authenticated Principal), so you are going to have a "guess"
at best this way. See http://java.sun.com/javaee/5/docs/api/javax/servlet/http/HttpSessionListener.html for details.

Alternatively, you can use a login mechanism specific way to do this. For example, with Form Login,
you can have your login.jsp count the authenticated principals and the logout.jsp decrement it.
There are additional clustering considerations here, but it should work on a single instance.

Regards,
Kedar
[Message sent by forum member 'km' (km)]

http://forums.java.net/jive/thread.jspa?messageID=278819