I am a newbie in programming and I was just wondering how you can retrieve a session and show it's contents in the jsp page? And i'm coding it in java. Thanks for your help.
Asked
Active
Viewed 776 times
4 Answers
2
session.getAttribute("attributeName")
Try look here: How to use session in jsp pages to get information?
And try to google it more next time. I typed "java jsp get session" and it gave me the link above.
1
JSP holds implicit objects, where you can get the values from session.
Some of the methods of that are
Methods of session object:
setAttribute(String, object)
getAttribute(String name)
getAttributeNames
isNew()
getCreationTime
getId
invalidate()
getLastAccessedTime
getMaxInactiveInterval
removeAttribute(String name)
reference link

Vinay Veluri
- 6,671
- 5
- 32
- 56
1
jsp has implicit object called session you can directly use session object in scriplet or in expression in jsp as:
<%
String name = (String) session.setAttribute("attribute_name");
%>

Shekhar Khairnar
- 2,643
- 3
- 26
- 44
1
Take a look here:
You can take data from a session in this way:
String name = request.getParameter( "username" );
and also add easily:
session.setAttribute( "theName", name );

ruhungry
- 4,506
- 20
- 54
- 98