Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List of session attributes 1

Status
Not open for further replies.

ZedEnter

Programmer
Sep 15, 2004
40
DE
Hi -

is it possible to get the list of ALL current loaded session attributes of a web application?

Greetz - Chris.
 
I politely suggest, for your own good, that before asking simple questions (not just in this forum, but in life), you at least consult the relevant documentation.

For example, if you had bothered to look at Sun's API docs for HttpSession object ( here : ) you will see that there is a method called getAttributeNames().

So call this, iterate through the enumeration, calling getAttribute() on each name to get its value.

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Hi,

I strongly agree with sedj, look at the JavaDoc's any how here is the example in case

Code:
// Get all session-scoped attributes
    HttpSession session = req.getSession();
    if (session != null) {
        Enumeration enum = session.getAttributeNames();
        for (; enum.hasMoreElements(); ) {
            // Get the name of the attribute
            String name = (String)enum.nextElement();
            // Get the value of the attribute
            Object value = session.getAttribute(name);
        }
    }

Cheers
Venu
 
Thx anyway for all your help...guess google doesn't do any good sometimes...

Greetz - Chris.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top