/** * This method is invoked when an attribute is removed from the ServletContext object * * @param se Description of the Parameter */ public void attributeRemoved(HttpSessionBindingEvent se) { ServletContext context = se.getSession().getServletContext(); try { if (se.getName().equals("User")) { UserBean thisUser = (UserBean) se.getValue(); if (thisUser != null) { // Internal SessionManager int userId = thisUser.getActualUserId(); if (userId > -2) { // If context reloaded, then SystemStatus is null, but user is valid Hashtable systems = (Hashtable) context.getAttribute("SystemStatus"); if (systems != null) { SystemStatus systemStatus = (SystemStatus) systems.get(thisUser.getConnectionElement().getUrl()); if (systemStatus != null) { // Remove the user from the session if it already is there SessionManager thisManager = systemStatus.getSessionManager(); if (thisManager != null) { UserSession thisSession = thisManager.getUserSession(userId); if (thisSession != null && thisSession.getId().equals(thisUser.getSessionId())) { if (System.getProperty("DEBUG") != null) { System.out.println( "ContextSessionListener-> Session for user " + userId + " ended"); } thisManager.removeUser(userId); if (System.getProperty("DEBUG") != null) { System.out.println( "ContextSessionListener-> User removed from valid user list"); } } } // Website Tracker Tracker tracker = systemStatus.getTracker(); tracker.remove(thisUser.getSessionId()); } } } } } } catch (Exception e) { e.printStackTrace(System.out); System.out.println("ContextSessionListener-> attributeRemoved Error: " + e.toString()); } }