Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Capture Session Timeout and Forward to JSP page

 
jarrett grantham
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am attempting to capture the session timeout and forward to some jsp page when timeout occurs. I am using Weblogic 6.1; can someone point me in the right direction on how to do this?
Thanks, Jarrett
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to do a session check before anything else for every request. This could be done, for example, with a filter (see javax.servlet.Filter) or by having each servlet to inherit from some kind of "SessionValidatorServlet", which redirects requests without a session to the login page.
 
Matthew Phillips
Ranch Hand
Posts: 2676
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can implement the HttpSessionListener interface. The sessionDestroyed method is called when the session is invalidated.
 
Matthew Phillips
Ranch Hand
Posts: 2676
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Matthew Phillips:
Your filter can implement the HttpSessionListener interface. The sessionDestroyed method is called when the session is invalidated.
 
jarrett grantham
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, I wasn't specific enough. I am using struts and I would like to automatically forward to some notification page when the session expires; but I want this to happen without user intervention. For example, a user leaves a browser unattended for 30 min & session timeout is 30 min; I would want the page to automatically forward to another page without the user submitting the page.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about putting a refresh interval into the HTML HEAD section of the page to "poll" session timeout?
 
Carlos Vassallo
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, I think that your timer might be on the client. JSP couldn`t do so much in that case.
I little bit ago, I really need to use that but my application runs over an intranet and all the browsers are IE, so the problem reduces to use this VB Script
'Object to hold the timer
Dim idTimer
'time of life of the session
Dim sessionTimeOut
function startTimer(vTime)
if time <> "" then
sessionTimeOut=vTime
else
vTime=sessionTimeOut
end if
idTimer = setTimeout ("goOut()", vTime)
end function
function goOut()
location.href="miUrl"
end function
function resetTimeOut()
clearTimer idTimer
startTimer ""
end function
I hope that this help.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64692
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about putting a refresh interval into the HTML HEAD section of the page to "poll" session timeout?

Since each "poll" will reset the session timeout, this will simply cause the session to never time out.
bear
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bear Bibeault:
Since each "poll" will reset the session timeout, this will simply cause the session to never time out.

Naturally this approach would require using some timestamp object within the HttpSession. A lot of work, ugly implementation, and a non-recommended solution in many other ways. Agreed.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic