You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jean-Noël Colin <jn...@gmail.com> on 2010/12/22 09:48:44 UTC

Getting detailed list of active sessions for a Context

Hi,

I'm developing a webapp and I would like to be able to display the list of active sessions for that specific webapp, in a specific page, and I'd like to get a detailed view: Session Id, Creation time, last activity, IP address, username (in case he's authenticated)

I searched forums and the web, and found the way to get access to the HttSession, by defining an HttpSessionListener. But I would like to get more info, like what's made available through the manager interface. 

I tried defining a Manager for the context (org.apache.catalina.session.StandardManager which is the default, btw), but can't find a way to access it from the jsp.

I also tried casting the HttpSession retrieved in the HttpSessionListener, without success.

Would you have any further suggestion?

Best regards

Jean-Noël Colin


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Getting detailed list of active sessions for a Context

Posted by Jean-Noël Colin <je...@fundp.ac.be>.
Many thanks Konstantin. I'll look into the Valve idea

Cheers

Jean-Noël

On 22 Dec 2010, at 12:23, Konstantin Kolinko wrote:

> 2010/12/22 Jean-Noël Colin <jn...@gmail.com>:
>> 
>> I also tried casting the HttpSession retrieved in the HttpSessionListener, without success.
> 
> That would be StandardSessionFacade, not a StandardSession.
> 
>> Would you have any further suggestion?
> 
> The manager webapp (aka HTMLManagerServlet) uses JMX. You may try
> using it as well.
> 
>> Session Id, Creation time, last activity, IP address, username (in case he's authenticated)
>> 
> 
> There is no IP address information in a session, and "username" that
> the Manager webapp displays is just a "Guessed User name" -- it looks
> for certain attribute names in the session, in case an authentication
> framework stored the information there.
> 
> You may implement a Filter (or Valve) that will "postprocess" a
> request and extract the information you are looking for from there
> (and store it as a session attribute, or put it in your own specific
> component).
> 
> Best regards,
> Konstantin Kolinko
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Getting detailed list of active sessions for a Context

Posted by Konstantin Kolinko <kn...@gmail.com>.
2010/12/22 Jean-Noël Colin <jn...@gmail.com>:
>
> I also tried casting the HttpSession retrieved in the HttpSessionListener, without success.

That would be StandardSessionFacade, not a StandardSession.

> Would you have any further suggestion?

The manager webapp (aka HTMLManagerServlet) uses JMX. You may try
using it as well.

> Session Id, Creation time, last activity, IP address, username (in case he's authenticated)
>

There is no IP address information in a session, and "username" that
the Manager webapp displays is just a "Guessed User name" -- it looks
for certain attribute names in the session, in case an authentication
framework stored the information there.

You may implement a Filter (or Valve) that will "postprocess" a
request and extract the information you are looking for from there
(and store it as a session attribute, or put it in your own specific
component).

Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Getting detailed list of active sessions for a Context

Posted by Jean-Noël Colin <je...@fundp.ac.be>.
Hi

Thanks for the feedback; actually, jsp or servlet is not really the point, since I'm using icefaces anyway.

So it seems that I can't get access to the list of sessions connected to my webapp, except the limited information provided by HttpSession?

Cheers

Jean-Noël

On 22 Dec 2010, at 10:19, Pid * wrote:

> On 22 Dec 2010, at 08:49, "Jean-Noël Colin" <jn...@gmail.com> wrote:
> 
>> Hi,
>> 
>> I'm developing a webapp and I would like to be able to display the list of active sessions for that specific webapp, in a specific page, and I'd like to get a detailed view: Session Id, Creation time, last activity, IP address, username (in case he's authenticated)
> 
> The below will get you the session details but not the username.
> 
>> 
>> I searched forums and the web, and found the way to get access to the HttSession, by defining an HttpSessionListener. But I would like to get more info, like what's made available through the manager interface.
>> 
>> I tried defining a Manager for the context (org.apache.catalina.session.StandardManager which is the default, btw), but can't find a way to access it from the jsp.
> 
> As you can see from the package name this is an internal tomcat class
> not a servlet spec class.
> 
> The servlet spec is not designed to permit access to the container
> (tomcat) implementation.
> 
>> I also tried casting the HttpSession retrieved in the HttpSessionListener, without success.
>> 
>> Would you have any further suggestion?
> 
> See PSIProbe and investigate JMX.
> Note: you may wish to perform logic in a Servlet rather than a JSP.
> 
> 
> p
> 
> 
>> 
>> Best regards
>> 
>> Jean-Noël Colin
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Getting detailed list of active sessions for a Context

Posted by Pid * <pi...@pidster.com>.
On 22 Dec 2010, at 08:49, "Jean-Noël Colin" <jn...@gmail.com> wrote:

> Hi,
>
> I'm developing a webapp and I would like to be able to display the list of active sessions for that specific webapp, in a specific page, and I'd like to get a detailed view: Session Id, Creation time, last activity, IP address, username (in case he's authenticated)

The below will get you the session details but not the username.

>
> I searched forums and the web, and found the way to get access to the HttSession, by defining an HttpSessionListener. But I would like to get more info, like what's made available through the manager interface.
>
> I tried defining a Manager for the context (org.apache.catalina.session.StandardManager which is the default, btw), but can't find a way to access it from the jsp.

As you can see from the package name this is an internal tomcat class
not a servlet spec class.

The servlet spec is not designed to permit access to the container
(tomcat) implementation.

> I also tried casting the HttpSession retrieved in the HttpSessionListener, without success.
>
> Would you have any further suggestion?

See PSIProbe and investigate JMX.
Note: you may wish to perform logic in a Servlet rather than a JSP.


p


>
> Best regards
>
> Jean-Noël Colin
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org