How to validate session before invalidate

J

jfuture_99

Before I call session.invalidate(), how can I make sure the session
has not been invalidate already because it will throw an exception if
it has.

Thanks

JF
 
T

Tony Morris

Before I call session.invalidate(), how can I make sure the session
has not been invalidate already because it will throw an exception if
it has.

Thanks

JF

I haven't tested these possiblities but you can give it a go:
- use HttpSession.isNew()
- Get the session back from the request object again
session = request.getSession(false);
if(session != null)
{
session.invalidate();
}

- or
session = request.getSession(true);
if(!session.isNew())
{
session.invalidate();
}

--
Tony Morris
(BInfTech, Cert 3 I.T.)
Software Engineer
IBM Australia - Tivoli Security Software
(2003 VTR1000F)
Sun Certified Programmer for the Java 2 Platform (1.4)
Sun Certified Developer for the Java 2 Platform
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top