|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
session information lost from one servlet to another - session id changes
Hi everyone!
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! Tiago |
|
#2
|
|||
|
|||
|
What are the urls to the two servlets? And what code are they using to get the session?
|
|
#3
|
|||
|
|||
|
Re:
The two servlets are in:
work/package1/WEB_INF/classes/*.class and work/package2/WEB_INF/classes/*.class And from jsp files in /package1/ there are html links to package2 like: <a href="../../package2/servlet/servletName">link</a> The code I use to get the session is: Code:
HttpSession session = request.getSession(); Hope it helps...I read something about session scope but don't know if there is something to do with it... Thanks! Tiago |
|
#4
|
|||
|
|||
|
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.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Java Help > session information lost from one servlet to another - session id changes |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|