my dog learned polymorphism*
The moose likes Servlets and the fly likes list all session variables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "list all session variables" Watch "list all session variables" New topic

list all session variables

scottie zman
Ranch Hand

Joined: Aug 08, 2001
Posts: 40
Can someone post some code to loop through all session variables and display their values?
Manjunath Reddy
Ranch Hand

Joined: Jul 26, 2001
Posts: 60
Enumeration e = session.getAttributeNames();
while ( e.hasMoreElements() )
String key = (String)e.nextElement();
out.println( key + " = " + session.getAttribute( key ) + " <br>" );
scottie zman
Ranch Hand

Joined: Aug 08, 2001
Posts: 40
thanks a bazillion.
I agree. Here's the link:
subject: list all session variables
Similar Threads
Thread safety in spring web application
session vs class variables
Regarding usage of scriplet variable in EL
How to display all session variables
All set session Variables List