Return-Path: Delivered-To: apmail-jakarta-tomcat-dev-archive@apache.org Received: (qmail 91678 invoked from network); 22 May 2002 15:04:50 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 22 May 2002 15:04:50 -0000 Received: (qmail 29025 invoked by uid 97); 22 May 2002 15:02:17 -0000 Delivered-To: qmlist-jakarta-archive-tomcat-dev@jakarta.apache.org Received: (qmail 28932 invoked by uid 97); 22 May 2002 15:02:16 -0000 Mailing-List: contact tomcat-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Tomcat Developers List" Reply-To: "Tomcat Developers List" Delivered-To: mailing list tomcat-dev@jakarta.apache.org Received: (qmail 28849 invoked by uid 50); 22 May 2002 15:02:15 -0000 Date: 22 May 2002 15:02:15 -0000 Message-ID: <20020522150215.28841.qmail@nagoya.betaversion.org> From: bugzilla@apache.org To: tomcat-dev@jakarta.apache.org Cc: Subject: DO NOT REPLY [Bug 9318] New: - HttpSession getMaxInactiveInterval() throws IllegalStateException X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT . ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE. http://nagoya.apache.org/bugzilla/show_bug.cgi?id=9318 HttpSession getMaxInactiveInterval() throws IllegalStateException Summary: HttpSession getMaxInactiveInterval() throws IllegalStateException Product: Tomcat 4 Version: 4.0.3 Final Platform: All OS/Version: All Status: NEW Severity: Normal Priority: Other Component: Servlet & JSP API AssignedTo: tomcat-dev@jakarta.apache.org ReportedBy: cwilson@andrews.edu I'm calling session.getMaxInactiveInterval() on a session after it has been invalidated. Tomcat is throwing an IllegalStateException and saying that method cannot be called on an invalid session. However, the Servlet 2.3 API docs do not state that IllegalStateException should be thrown (as it is with many other methods in HttpSession) from getMaxInactiveInterval(). The reason I've run into this problem is because I'm trying to write a HttpSessionAttributeListener that determines if the session is being explicitly invalidated or if it timed out. The Servlet 2.3 spec (section 10.7) states, "It is often useful in tracking sessions to know whether a session became invalid because the container timed out the session, or because a web component within the application called the invalidate method. The destinction may be determined indirectly using listeners and the HTTPSession API methods." If I can't call getMaxInactiveInterval() on an invalidated session, how can I determine if the session was invalidated due to time out? Is this a bug in Tomcat? It seems so since it doesn't follow the API docs for this call. Here is a HttpServletListner the demonstrates the problem: import javax.servlet.http.HttpSessionListener; import javax.servlet.http.HttpSessionEvent; import javax.servlet.http.HttpSession; public class TestListener implements HttpSessionListener { public void sessionCreated(HttpSessionEvent httpSessionEvent) { } public void sessionDestroyed(HttpSessionEvent httpSessionEvent) { // ok session should be invalid here... // lets test some assertions // let put it in a try block to catch any exceptions try { HttpSession session = httpSessionEvent.getSession(); // lets make sure session is not null System.out.println(session == null); // ok lets try last access time // this SHOULD work even if session is invalid // javadocs say it will... System.out.println(session.getLastAccessedTime()); // ta-da it does // ok if that worked then this should work too // javadocs do not say it throws IllegalStateException System.out.println(session.getMaxInactiveInterval()); // whoops this breaks... // javadocs say this shouldn't happen // Servlet spec (10.7) implies using this method to see if // a session is invalid because of timeout as opposed // to explicit call to session.invalidate(); // now, we won't get here cause the above fails // but just to see if the session is invalid // lets call something that the javadocs DO say should // throw IllegalStateException on an invalid session session.invalidate(); } catch(Exception e) { e.printStackTrace(); } } } -- To unsubscribe, e-mail: For additional commands, e-mail: