GeeCON Prague 2014*
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
Author

asp to jsp growing pains

Anonymous
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?
Thanks.
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
Website: http://www.philhanna.com


Phil Hanna<BR>Sun Certified Programmer for the Java 2 Platform<BR>Author of :<BR><A HREF="http://www.amazon.com/exec/obidos/ASIN/0072127686/electricporkchop/107-3548162-1137317" TARGET=_blank rel="nofollow">JSP: The Complete Reference</A><BR><A HREF="http://www.amazon.com/exec/obidos/ASIN/0072124253/electricporkchop/107-3548162-1137317" TARGET=_blank rel="nofollow">Instant Java Servlets</A>
 
GeeCON Prague 2014
 
subject: asp to jsp growing pains