jsp - Any tool to view web session attributes? -


I use jsp / Servlets for my web layer. Is there a tool to check session attributes in the web session?

Of course. It's not really a device, but a simple code snippet. Add somewhere in a servicelet / JSP / filter:

  session session = request .getSession (); Calculation attribute name = session.get attribute name (); While (Attributomom. Hammer Elements ()) {String name = AttributeName. Newcastle Element (); String value = session.getAttribute (name); System.out.println (name + "=" + value); }  

and you will have all the attributes of the session printed on the console.

Alternatively, in JSP:

  & lt; For C: each item = "$ {sessionScope}" var = "attr" & gt; $ {Attr.key} = $ {attr.value} & lt; Br> & Lt; / C: foreach & gt;  

This will print all the attributes of the session on the page.

Update: It is known that you have a misunderstanding of session. Session data is on server-side The client only maintains a unique identifier by which its data is referenced on the server. This identifier is most often a "session cookie", but it can also be a part of the URL (JSACINID). That's why customers can see the contents of the session not if you want your session attributes to be displayed with their actual values ​​(separate from their hash code), then their toString ( ) Override the method.


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -