Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why am I getting a null session?

Status
Not open for further replies.

FreshmenProgrammer

Programmer
Jan 16, 2006
42
CA
Thanks in advance for helping me with my question. I just have a question about sessions. I log in my app login page then I set an id in the session eg.

Code:
request.getSession().setAttribute("Id", Id);

So it's set in the session (i comfirmed this by pulling it out of the session in the same controller and printing). Now I come into the same app from a link in an email about 30 seconds after I log in. If Id is null I want to be sent to the app login page else just sent right into the app But for some reason when I come into the app from an email link i get a null value for Id when I just set it in the login controller. Anyone know why. Thanks?
 
Does the link open a new browser window ?

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Code:
String Id = (String)request.getSession().getAttribute("Id");

if(Id == null){
response.sendRedirect(response.encodeRedirectURL("a.jsp"));
}else{
response.sendRedirect(response.encodeRedirectURL("a.jsp"));
}

the code will be something like this in the email controller
 
What im trying to do is in a previous app an email request is sent which is a link in an email when you click on it if you are logged into the app that handles that request go right into the app else you are redirected to the loggin page to loggin the program.
 
If its a new browser, then its a new session ...

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Is there a way maybe when you log into the app to set a session ID as the loggin name. Then you can get that session from a different browser window and check if your attributes are null or not.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top