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!

Share session between two servlet

843840Nov 9 2002 — edited Nov 10 2002
hi all
I create a session in one servlet and i use another servlet to get the session in the same browser but it fail.
what is the code for get the session?
//Create session
String USER = "USER"
session.putValue(USER, ulog);
HttpSession session = req.getSession(true);
ulog = new User(); //User is a class
session.putValue(USER, ulog);

//Get session
String USER = "USER";
HttpSession session = req.getSession(true);
User ulog = (User) session.getValue(USER); //User is a class, this line fail
What wrong in the Get session part?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 8 2002
Added on Nov 9 2002
7 comments
144 views