| Author |
session variable
|
ajithsasi kumar
Greenhorn
Joined: Apr 06, 2008
Posts: 21
|
|
|
how to access a session variable in servlet from a jsp
|
 |
Seetharaman Venkatasamy
Ranch Hand
Joined: Jan 28, 2008
Posts: 5575
|
|
Hi ajithsasi kumar, You can access session variable from any component of your application.. in jsp just set the value & in servlet get the value  --------------------------------------- jsp: session.setAttribute("key","value");//session is an implicit Object in jsp servlet: HttpSession session=request.getSession(false); session.getAttribute("key");//returns Object value --------------------------------------------- Thanks & regards, seetharaman
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14672
|
|
|
Do you want to access a session variable from JSP or from a servlet ?
|
[My Blog]
All roads lead to JavaRanch
|
 |
sudhir nim
Ranch Hand
Joined: Aug 29, 2007
Posts: 212
|
|
And dont forget to set session attrtibute of page directive :0) <%@page ... session="true" ..%>
|
[Servlet tutorial] [Servlet 3.0 Cook Book]
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
Originally posted by ajithsasi kumar: how to access a session variable in servlet from a jsp
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
Bosun Bello
Ranch Hand
Joined: Nov 06, 2000
Posts: 1506
|
|
This happens to be the default value of this attribute. So it's not necessary to set it, unless if the page should not be part of the session, then it needs to b set to false.
Originally posted by sudhir: And dont forget to set session attrtibute of page directive :0) <%@page ... session="true" ..%>
|
Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
"sudhir", Please check your private messages regarding an important administrative matter. -Ben
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56215
|
|
Varsha Garud, Your post was moved to a new topic.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56215
|
|
Varsha Garud, Your post was moved to a new topic.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56215
|
|
Varsha Garud, Your post was moved to a new topic.
|
 |
 |
|
|
subject: session variable
|
|
|