#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2002
    Posts
    14
    Rep Power
    0

    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. #2
  3. No Profile Picture
    Moderator =(8^(|)
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2002
    Location
    Sacramento, CA
    Posts
    1,710
    Rep Power
    14
    What are the urls to the two servlets? And what code are they using to get the session?
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2002
    Posts
    14
    Rep Power
    0

    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
  6. #4
  7. No Profile Picture
    Moderator =(8^(|)
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2002
    Location
    Sacramento, CA
    Posts
    1,710
    Rep Power
    14
    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.

IMN logo majestic logo threadwatch logo seochat tools logo