October 5th, 2002, 06:51 AM
session information lost from one servlet to another - session id changes
I made an web application based on 2 servlets (two different packages). One package imports the other.
In the first one (used for login - logoff purposes) I store a string "strEmployeeID" in the session. But when I link (html) to the second servlet, this information is lost. (Two different folders, one for each component, but in the WEB-INF\classes folder there are both packages with all classes for the two servlets).
Searching a bit, with session.getId(), I remarked that the sessionId changes too, without closing the browser window, which normally shouldn't happen...of course if it isn't the same session, all the information relative to it is lost.
Does someone have an idea why the session changes? Should I use the context instead of the session? Running Tomcat 4.0 on Explorer 6.0.2600.
Thanks a lot for your help!
October 6th, 2002, 06:58 PM
What are the urls to the two servlets? And what code are they using to get the session?
October 7th, 2002, 07:06 AM
The two servlets are in:
And from jsp files in /package1/ there are html links to package2 like:
The code I use to get the session is:
Hope it helps...I read something about session scope but don't know if there is something to do with it...
HttpSession session = request.getSession();
October 7th, 2002, 10:26 AM
Ya, your servlets are in different contexts, so they won't be able to share sessions. You're going to need to put them both into the same WEB-INF/classes folder.