• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

session tracking

 
liliana punkt
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Sloan Bowman
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 149
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your help!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic