How about:

if(session.getAttribute("myattrib")==null) {

}


Tim Davidson wrote:


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

-----Original Message-----
From: Justin Ruthenbeck [mailto:[EMAIL PROTECTED]
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?
i.e.
if( !session.isInvalidated()) <-- what should go here?
{
       session.invalidate();
}

to prevent the following exception:
"org.apache.jasper.JasperException: invalidate: Session already invalidated"



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


try
{
    session.getAttributeNames();
}
catch (java.lang.IllegalStateException isse)
{
    // Session is already invalid
}

justin

____________________________________
Justin Ruthenbeck
Software Engineer, NextEngine Inc.
justinr - AT - nextengine DOT com
Confidential
   See http://www.nextengine.com/confidentiality.php
____________________________________


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



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








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



Reply via email to