Two Laptop Bag
The moose likes Servlets and the fly likes asp to jsp growing pains Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "asp to jsp growing pains" Watch "asp to jsp growing pains" New topic

asp to jsp growing pains

Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Please... help me.
With asp, you can print your session or request object contents with the following code:

For those of you that aren't familiar with asp, the resulting output would be something like:
NameOfSessionVariable1 = ValueOfSessionVariable1
NameOfSessionVariable2 = ValueOfSessionVariable2
NameOfSessionVariable3 = ValueOfSessionVariable3
How is this done with jsp?
Phil Hanna
Ranch Hand

Joined: Apr 05, 2001
Posts: 118
The session object has a method named getAttributeNames(), which returns an enumeration of the names of all objects bound to the session. You can loop through the enumerated names and retrieve the session values with session.getAttribute(name):
Enumeration names = session.getAttributeNames();
while (names.hasMoreElements()) {
String name = (String) names.nextElement();
Object value = session.getAttribute(name);
Here is an example of the technique that uses a table to print the retrieved attributes:

Phil Hanna
Sun Certified Programmer for the Java 2 Platform
Author of :
JSP: The Complete Reference
Instant Java Servlets

Phil Hanna<BR>Sun Certified Programmer for the Java 2 Platform<BR>Author of :<BR><A HREF="" TARGET=_blank rel="nofollow">JSP: The Complete Reference</A><BR><A HREF="" TARGET=_blank rel="nofollow">Instant Java Servlets</A>
I agree. Here's the link:
subject: asp to jsp growing pains
It's not a secret anymore!