Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Null session variable

843838Nov 28 2005 — edited Nov 28 2005
Ok, i have a problem which is really annoying me and i have been stuck on for a while. I am developing a website for my brothers company and am really stuck for time for the launch date. I developed a website last year which worked fine and i am re using the code from that. I am setting a session variable "sessEmail" when the user logs in and want to retrieve it when they go to add a produt to their cart. Here is my code

String Email = request.getParameter("txtEmail");
String Password = request.getParameter("txtPassword");
session.setAttribute("sessEmail",Email);


Object o = session.getAttribute("sessEmail");
String s = o.toString();
out.print(s);

I am just printing out the "sessEmail" to make sure it is working. It works fine when i try and retrieve the session variable on the same page were i set it but on a seperate page it wont work. It is returning a null pointer exception because the session variable has no value. It is occuring when i try to convert an object to a string.

Any help would be much appreciated as i am stuck for time.

Cheers
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 26 2005
Added on Nov 28 2005
2 comments
440 views