aspose file tools
The moose likes Struts and the fly likes Session checking with Struts 2 Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Reply Bookmark "Session checking with Struts 2" Watch "Session checking with Struts 2" New topic
Author

Session checking with Struts 2

Rusty Enisin
Ranch Hand

Joined: May 26, 2005
Posts: 107
I am using and AJAX call to determine if the user's session has timed out. I am using Struts 2. I tried implementing ServletRequestAware and then getting the session from that like this:



But it seems that the session is getting created by struts because the session is always not null (Even though I know the session was killed).

Any ideas on how to do this?


The squeaky wheel gets the grease. Well, that or replaced...
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
I've found that getSession(true) is not a good way to check for a valid session in Struts 1 or Struts 2. The method I've found most effective is to put some object in the session when the user logs on. Then check for the existence of that object. If it's not there, you know the session has expired.


Merrill
Consultant, Sima Solutions
Rusty Enisin
Ranch Hand

Joined: May 26, 2005
Posts: 107
Thank you. That makes sense. I will do it that way.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Session checking with Struts 2
 
Similar Threads
How can Action class will get access to HttpServletRequest to access data??
checking to see if session timed out
[struts 2] getting null on getSession
Session issue with Glassfish (Linux)
Design pattern used in Struts Framework ?