See my comments below...

Chris Wilson

[EMAIL PROTECTED]
www.wondergeek.com

> -----Original Message-----
> From: Scott Judd [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, May 21, 2002 3:17 PM
> To: Tomcat Users List
> Subject: Re: HttpSession invalidate bug???
> 
> Hi Chris,
> 
> Session.invalidate() is being called by Tomcat on session timeout,
which
> is
> the same call that is given when you implicitly invalidate the session
in
> your servlet code. 

Sure that makes sense, that's what I understood was happening...  I
don't think that's the problem though.  I fully expect the session to be
invalid.

> Once session.invalidate() has been called, you no
> longer
> have any session properties to get, including your session listener.
Also,
> you're gonna need to add some properties to your session object to
> determine
> how/why the session was invalidated.

This is the problem...  The Servlet spec implies (10.7) that you CAN use
at least some of the HttpSession API's to determine if the session is
invalid because it timed out.  I assume that you would do that with the
following code...

if((System.currentTimeMillis() - session.getLastAccessedTime())
  > session.getMaxInactiveInterval()) {
  // session timed out
}

If I run that code on an invalidated session the getLastAccessedTime()
call works just fine (the javadocs say that it does not throw any
exceptions) which is expected.  However, the getMaxInactiveInterval()
call fails with an InvalidStateException (this is thrown even though the
javadocs DO NOT specify that it should be) which is not expected.

It seems to be that there is no way for me to determine if a session is
invalid (because it timed out) in a listener without
getMaxInactiveInterval().  Now either the spec (10.7) is referring to
some other combination of calls, or the javadocs are wrong, or Tomcat is
throwing an IllegalStateException when it shouldn't be (most likely).

So my question is if the Tomcat developers can justify why
getMaxInactiveInterval() should throw an exception when called on an
invalid session, how can I achieve section 10.7 in the spec?

> Just using the API calls without any
> "support staff" will not be sufficient.

Again, this is not what the spec implies.  It says I should be able to
do it with HttpSession directly.

Thanks for the help!

> 
> scott
> 
> 
> ----- Original Message -----
> From: "Chris Wilson" <[EMAIL PROTECTED]>
> To: "tomcat" <[EMAIL PROTECTED]>
> Sent: Tuesday, May 21, 2002 2:38 PM
> Subject: HttpSession invalidate bug???
> 
> 
> > Hello,
> >
> > 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.
> >
> > Thanks in advance for any insight.
> >
> > Chris Wilson
> >
> > [EMAIL PROTECTED]
> > www.wondergeek.com
> >
> >
> >
> > --
> > To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> >
> >
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:tomcat-user-
> [EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:tomcat-user-
> [EMAIL PROTECTED]>



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to