aspose file tools*
The moose likes Servlets and the fly likes session tracking Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "session tracking" Watch "session tracking" New topic
Author

session tracking

liliana punkt
Greenhorn

Joined: Dec 23, 2002
Posts: 16
Hi,

I'm trying to set a session in a servlet (running on TOMCAT) in this way:

session.setAttribute("name",object);
response.sendRedirect(/xy/web.jsp);

In web.jsp I try to check the attribute with:
session.getAttribute("name");

But it is null! I know, that for cookies you have to specify the path, where the Browser will send the Cookie. Is this also true for HTTPSessions? What can I do?

thanks,
liliana
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12682
    
    5
Since the servlet engine typically manages the session using the id stored in a cookie, yes - the visibility rules that apply to cookies apply to sessions. If your redirect is to another "web application" it won't see the session created for the initial "web application"
Bill


Java Resources at www.wbrogden.com
Sloan Bowman
Ranch Hand

Joined: Jan 21, 2003
Posts: 107
Are you initilizing the session in the jsp or servlet that you are using to get the session object. For example in your servlet:


or in jsp:
arnel nicolas
Ranch Hand

Joined: Dec 16, 2003
Posts: 149
The sendRedirect method rexecute the url request from the client. So if you want to put an object in your session you may want to use the forward method of the request.
liliana punkt
Greenhorn

Joined: Dec 23, 2002
Posts: 16
Thanks for your help!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: session tracking
 
Similar Threads
on EJB Topic
storing password into session with filters
session.invalidate()
How can i get session value in my JSP page using JSTL
implicit objects in jsp