| Author |
Program to set use a session, please
|
Zaynab Ejaz
Greenhorn
Joined: Nov 14, 2008
Posts: 6
|
|
I've created a HttpSession in a servlet and initialised it with a parameter, how can I access dat parameter in a JSP page, should set a Page Attribute or sumthing if so wat Thnx in advance ^_^
|
 |
Patricia Samuel
Ranch Hand
Joined: Sep 12, 2007
Posts: 300
|
|
Originally posted by Zaynab Ejaz: I've created a HttpSession in a servlet and initialised it with a parameter, how can I access dat parameter in a JSP page, should set a Page Attribute or sumthing if so wat Thnx in advance ^_^
Your question is not pretty clear. Are you talking about how can you use the value that you have set in session. If so, request.getSession().getParameter("name") can help you in retrieving the value.
|
 |
Mourouganandame Arunachalam
Ranch Hand
Joined: Oct 29, 2008
Posts: 395
|
|
As mentioned, if you have created a variable and stored in session scope, you can always access the variable until the session gets expired, doesn't matter if you are in servlet or jsp. You can try the same as suggested above. Pass the correct session variable name in the getParameter() method. Mourougan
|
Mourougan
Open Source leads to Open Mind
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56192
|
|
No, getParameter() is not correct. The method is named getAttribute(). And if you are following modern standards and using the EL rather than scriptlets on the JSP, you don't even need to bother with that.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Zaynab Ejaz
Greenhorn
Joined: Nov 14, 2008
Posts: 6
|
|
Yes I wanted to use the value I had set in the session heres the code I wrote String sname = String.valueOf(request.getSession().getAttribute("name")); I had an outdated example that I couldn't use thanks, you guys are a great help
|
 |
 |
|
|
subject: Program to set use a session, please
|
|
|