tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Murray" <>
Subject RE: Checking for invalidated session
Date Fri, 01 Aug 2003 13:14:15 GMT
I'm trying to ensure that a session is newly created when I reach my index
page.  The logic is reversed from your question but I believe the principle
is the same inasmuchas I want to know whether or not a valid session exists.

  if (! session.isNew() )

The redirect is to cause the page to be reloaded after the invalidate()
since JSP, by default, creates a new session when the page is loaded.

In the body of the page I had a line
  <p>You are in session.  The session id is <%=session.getId()%>.
which produces "The session id is null" prior to inserting the redirect.
After the redirect was inserted the html was not sent to the browser until a
valid session was established at which time each visit to or browser refresh
of the page produced a new session id.

Someone with more than three months of playing with this as a spare time
hobby feel free to critique the solution please.


-----Original Message-----
From: Tim Davidson []
Sent: Friday, 1 August 2003 18:10
To: Tomcat Users List
Subject: RE: Checking for invalidated session

But surely theres a better way?
 Whould I be better off replacing "session.invalidate()" with "session =

-----Original Message-----
From: Justin Ruthenbeck []
Sent: Thursday, July 31, 2003 6:44 PM
To: Tomcat Users List
Subject: Re: Checking for invalidated session

At 08:31 AM 7/31/2003, you wrote:
>How can you check to see if a session has already been validated?
>  if( !session.isInvalidated()) <-- what should go here?
>         session.invalidate();
>to prevent the following exception:
>"org.apache.jasper.JasperException: invalidate: Session already

If you don't want to just catch and ignore the JasperException, then use
something like this:

catch (java.lang.IllegalStateException isse)
     // Session is already invalid


Justin Ruthenbeck
Software Engineer, NextEngine Inc.
justinr - AT - nextengine DOT com

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message