• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Tomcat: getActiveSessions, getSessionParams(sID) -> How?

Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I lost some hours to find a solution, finally it would be great if you could help me.

I found out how to store sessionIDs with a SessionListener.
However, later when I request them I want to get each user's session data for each running session.

Vector sessionIDs = tomcat.getSessions();
for (int s=0; s<sessionIDs.size(); s++)
String sessionID = (String) session.IDs.get(s);
HttpSession usersession = tomcat.getSession(sessionID );
System.out.println("username: " + (String)usersession.getAttribute("username")):

Is this possible?
I read someting about a StandardManager and the method findSession ... well, but don�t get it ... how do I get the right (actual) instance for this manager?

Maybe someone can help me,
that would be great.

Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rather than going through tomcat-specific classes, how about storing a reference to the Session object, while in your session listener.

So don't just store the ID, which you'd then use to retrieve (through tomcat-specific stuff, the HttpSession).... just store the HttpSession
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!