×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Why am I getting a null session?

Why am I getting a null session?

Why am I getting a null session?

(OP)
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?

RE: Why am I getting a null session?

Does the link open a new browser window ?

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
http://www.primrose.org.uk

RE: Why am I getting a null session?

Or is the request redirected in any moment?

Cheers,
Dian

RE: Why am I getting a null session?

(OP)
Yes new window.  But shouldn't you still be able to see the session.

RE: Why am I getting a null session?

(OP)

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

RE: Why am I getting a null session?

(OP)
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.

RE: Why am I getting a null session?

If its a new browser, then its a new session ...

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
http://www.primrose.org.uk

RE: Why am I getting a null session?

(OP)
Oh really :(  Is there any way to get into the old session at all.  

RE: Why am I getting a null session?

(OP)
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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close