• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

asp to jsp growing pains

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic