Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Session checking with Struts 2

 
Rusty Enisin
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rusty Enisin
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you. That makes sense. I will do it that way.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic