File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Servlets
Bookmark "session tracking" Watch "session tracking" New topic

session tracking

liliana punkt

Joined: Dec 23, 2002
Posts: 16

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


In web.jsp I try to check the attribute with:

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?

William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
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"
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

Joined: Dec 23, 2002
Posts: 16
Thanks for your help!
I agree. Here's the link:
subject: session tracking
It's not a secret anymore!