#1
  1. kill 9, $$;
    Devshed Supreme Being (6500+ posts)

    Join Date
    Sep 2001
    Location
    Shanghai, An tSín
    Posts
    6,897
    Rep Power
    3887

    HttpSession dropping Attributes


    I'm using a HttpSession object in a servlet to hold the user's information. Currently, there's only one attribute in the session, which is a User object to hold this data. This is set by my login servlet. In another servlet, I'm getting that object to check if the user is logged in or not.
    Code:
    User u = (User) session.getAttribute("user");
    if (u != null) {
       // do stuff
    }
    else {
       // user is not logged in
    }
    This can work a few times after the user has logged in but eventually (after refreshing the page a few times) the User object becomes null. I don't user setAttribute() or invalidate() anywhere in this particular servlet and the session ID is the same, so it hasn't timed out.

    I also don't call any methods in the User object that change it in any way.

    Has anyone had this problem before? The servlets are running on Tomcat 4.1.18
  2. #2
  3. No Profile Picture
    Clueless llama
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Feb 2001
    Location
    Lincoln, NE. USA
    Posts
    2,353
    Rep Power
    117
    I have never had this problem, but I do not use Tomcat 4.1. Can we see the jsp and the servlet?
  4. #3
  5. kill 9, $$;
    Devshed Supreme Being (6500+ posts)

    Join Date
    Sep 2001
    Location
    Shanghai, An tSín
    Posts
    6,897
    Rep Power
    3887
    Is it possible that the data in the User object could be too big for the session? It hadn't occurred to me until now that a session Attribute may have a maximum size.
    ~ishnid

IMN logo majestic logo threadwatch logo seochat tools logo