File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes getting session value in JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "getting session value in JSP" Watch "getting session value in JSP" New topic

getting session value in JSP

dasari sudha

Joined: Feb 20, 2005
Posts: 5
In my application i am calling one JSP from servlet. I set some
attributes in session object in servlet. but getting problem in accessing session object in JSP (getting attribute values as null). does it mean when we specify <%@ page session="true"%> on jsp page, it creates new session
object and so i am getting null values for previously set attributes ?
if i give <%@ page session="false"%>, then i can not get access to
session object.

any help ??

Eugene Lucash
Ranch Hand

Joined: Feb 19, 2005
Posts: 77
consider not to use such directive at all <%@ page session=""%>
nor true, nor false.
Ariel Valentin
Ranch Hand

Joined: Jan 30, 2004
Posts: 44
<%@ page session="true"%>
Isn't that equivalent to:
HttpSession session = request.getSession(true);
I believe that the directive is implictly set to true but Eugene is correct don't write what you don't have to:

in my application i am calling one JSP from servlet. I set some
attributes in session object in servlet.

How exactly are you doing this? I have run into trouble using http://localhost:someportnumber with session objects in firefox if this is your probelm try your http://yourmachinename:yourportnumber instead.
Also careful you are not blocking cookies you will need it for jsessionid if not using url rewriting.

A. Valentin
I agree. Here's the link:
subject: getting session value in JSP
Similar Threads
returning a resultset
<jsp:setProperty> sets null values in the bean
Retrieving data from a servlet then forward to JSP page
Can I use Servlet Session in JSP Page.
How to get values of object