Tomcat sessions user's id list

R

Rejean

Hi,

I'm looking for how to retrieve the list of user's, log into and
application in tomcat, via tomcat manager I can see the number of
sessions, but I need to retrieve the user id of those sessions.

Thanks!
 
W

William Brogden

Hi,

I'm looking for how to retrieve the list of user's, log into and
application in tomcat, via tomcat manager I can see the number of
sessions, but I need to retrieve the user id of those sessions.

Thanks!

You will have to do some programming - look into the various
session "Listener" interfaces such as HttpSessionListener.
Bill
 
R

Rejean

William Brogden said:
You will have to do some programming - look into the various
session "Listener" interfaces such as HttpSessionListener.
Bill

Ok Thanks, I did a little research, created a tag in the web.xml
<listener>
<listener-class>
ca.qc.toto.cop.SessionListener
</listener-class>
</listener>


And created a class
/*
* Created on Aug 5, 2004
*
* To change the template for this generated file go to
* Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and
Comments
*/
package ca.qc.toto.cop;

import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

/**
* @author cf1926
*
* To change the template for this generated type comment go to
* Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and
Comments
*/
public class SessionListener implements HttpSessionListener {

private static Map sessions = new HashMap();

/* (non-Javadoc)
* @see javax.servlet.http.HttpSessionListener#sessionCreated(javax.servlet.http.HttpSessionEvent)
*/
public void sessionCreated(HttpSessionEvent arg0) {
System.out.println("Nouvelle session");
sessions.put("Nouveau nom","");
System.out.println(arg0.getSession().getId());

}

/* (non-Javadoc)
* @see javax.servlet.http.HttpSessionListener#sessionDestroyed(javax.servlet.http.HttpSessionEvent)
*/
public void sessionDestroyed(HttpSessionEvent arg0) {
sessions.remove("Nouveau nom");
}

/**
* @return
*/
public static Map getSessions() {
return sessions;
}

/**
* @param map
*/
public static void setSessions(Map map) {
sessions = map;
}

}

But now I can seem to get the remote user login id .... any ideas.

Thanks!
 
Joined
Aug 20, 2007
Messages
3
Reaction score
0
HttpSessionListener not generating events

In my tomcat based test server for a special purpose, ALL listeners are reporting and behaving perfectly, except that the HttpSesssionListener is not reporting a sessionEvent even though the doPost method in the servlet is doing its job perfectly. No error in code, I can assure you.This test is being conducted locally on the same machine.

Not sessionCreated not sessionDestroyed.

Any ideas on why HttpSessionEvent is not generated? Or detected? The web.xml for this application deployed is reproduced below in extract.

</description>
<servlet>
<servlet-name>LoadCandidateJSP</servlet-name>

<servlet-class>tcsi.webcvws.services.web.LoadCandidateJSP</servlet-class>
<init-param>
<param-name>readonly</param-name>
<param-value>false</param-value>
</init-param>

<load-on-startup>1</load-on-startup>

<session-config>
<session-timeout>1</session-timeout>
</session-config>
</servlet>
<listener>
<listener-class>
tcsi.webcvws.services.web.CandidateSessionListener
</listener-class>
</listener>


Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top