getSession(false) never return's null?

Z

zidered

Using weblogic 8.1 (sp3), Tomcat 5, JDK 1.4.1_07, struts 1.1

Am trying to detect when a user's session has expired so as to forward to
app start page. In each od my Action's I have this line -

HttpSession session = request.getSession(false);

Using the false parameter is supposed to return null if expired but it
always return a session object. isNew() returns true so it creating a new
session object each time. No matter what I try on both servers it will not
return null!

Any ideas? - is this a known bug? or wot?

Found what looks like a way around it using the request's
isRequestedSessionIdValid() method which seems to do the trick but would
love to know what the other problem is!

thanks

harry
 
S

Sudsy

zidered wrote:
Using the false parameter is supposed to return null if expired but it
always return a session object. isNew() returns true so it creating a new
session object each time. No matter what I try on both servers it will not
return null!

First off, when using Struts don't try to mess with sessions. Let the
container handle the nastiness for you. Also, if in your controller
tag in struts-config.xml you have locale="true" specified (something
I usually do) then Struts will always try to create a new session to
contain the browser's locale.
What I use to manage login is simply add a USERNAME or USERID token
to the session context. Easy to check for, can even be done in filters.
Logout or timeout results in the token disappearing so you can redirect
to the login page.
 

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
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top