Results 1 to 2 of 2
  1. #1
    bbq
    bbq is offline Senior Member
    Join Date
    Jun 2007
    Posts
    132
    Rep Power
    0

    Default Using HttpSessionListener

    I'm developing with an HttpSessionListener

    My code is:
    Java Code:
    public class SessionListener implements HttpSessionListener, IHttpConstants {
    
      public void sessionCreated(HttpSessionEvent event) {
         HttpSession session = event.getSession();
        _log.info("Session [" + session.getId() + "] has been created.");
      }
    
      public void sessionDestroyed(HttpSessionEvent event) {
        HttpSession session = event.getSession();
        _log.info("Session [" + session.getId() + "] is about to be destroyed.");
        User user = (User) session.getAttribute(SESSION_ATTRIBUTE_USER);
        if (user != null) {
          _userTracker.logOut(user);
        }
      }
    
      private UserTracker _userTracker = UserTracker.getInstance();
      private static Category _log = Category.getInstance("log");
    }
    When the sessionDestroyed method is called a nexception appears : java.lang.IllegalStateException: getAttribute: Session already invalidated is thrown at the line where the user is retrieved from the session.

    what is the problem?

  2. #2
    Heather is offline Senior Member
    Join Date
    Jun 2007
    Posts
    164
    Rep Power
    7

    Default

    sessionDestroyed is called when it's invalidated
    you're using getAttribute() method, and it results invalid state exception

Similar Threads

  1. How to implement HttpSessionListener in JSP
    By Srikanth816 in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 04-16-2008, 09:22 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •