You need to implement a Session Listener like this.
public class SessionHelper implements HttpSessionListener {private static Hashtable sessionsById = null;
/**
* @see javax.servlet.http.HttpSessionListener#sessionCreated(javax.servlet.http.HttpSessionEvent)
*/
public void sessionCreated(HttpSessionEvent sessionEvent) {
if (sessionsById == null) {
sessionsById = new Hashtable();
}
HttpSession session = sessionEvent.getSession();
String sessionId = session.getId();
sessionsById.put(sessionId, session);
}
/**
* @see javax.servlet.http.HttpSessionListener#sessionDestroyed(javax.servlet.http.HttpSessionEvent)
*/
public void sessionDestroyed(HttpSessionEvent sessionEvent) {
}
}
Then you can access the sessions via this session helpers Hashtable.
Finally you need to add the following to your web.xml.
<web-app id="WebApp"> <display-name>blah....</display-name> <listener> <listener-class>SessionHelper</listener-class> </listener> .................. etc
Cheers,
Mark
----Original Message Follows---- From: Bernhard Slominski <[EMAIL PROTECTED]> Reply-To: "Tomcat Users List" <[email protected]> To: 'Tomcat Users List' <[email protected]> Subject: AW: Getting other Sessions Date: Wed, 23 Feb 2005 10:31:00 +0100
Hi Matt, Joseph,
you're right, I was not reading Joseph's question properly, I thought he want wants "all objects IN the session". I also can't think of another solution than Antony mentioned earlier.
Bernhard
-----Urspr�ngliche Nachricht----- Von: Dale, Matt [mailto:[EMAIL PROTECTED] Gesendet: Mittwoch, 23. Februar 2005 10:25 An: Tomcat Users List Betreff: RE: Getting other Sessions
Hi,
That doesn't answer Joseph's question. It tells him how to access the objects in his own session but not how to access other peoples sessions. I would be interested to see how this is done as well.
Ta Matt
-----Original Message----- From: Bernhard Slominski [mailto:[EMAIL PROTECTED] Sent: 23 February 2005 09:17 To: 'Tomcat Users List' Subject: AW: Getting other Sessions
Hi, HttpSession.getAttributeNames() should do what you want!
From the javadoc:
"getAttributeNames
public java.util.Enumeration getAttributeNames()
Returns an Enumeration of String objects containing the names of all the
objects bound to this session."
Cheers
Bernhard
-----Urspr�ngliche Nachricht----- Von: Joseph Shraibman [mailto:[EMAIL PROTECTED] Gesendet: Mittwoch, 23. Februar 2005 05:18 An: [email protected] Betreff: Getting other Sessions
I want to make an admin page in my application. I needs to be able to get access to all the current Session objects to access their attributes. Is this possible?
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
