0

I want to apply the some code in the header of all my jsp pages where it will automatically detect when the session is timeout and redirect to login page.

Is it possible?

Any one have some idea Please tell me

Rohini
  • 117
  • 1
  • 5
  • 14

1 Answers1

1

You can check session timed out with JavaScript. Try following:

var timeOut = 1000 * 60 * 30; // Default session time out 30 minutes in jsp
var now = new Date().getTime();
var check;
check= function(){
    if(new Date().getTime() > now + timeOut){
        window.location='login.jsp' // Which page you need
    }else{
        window.setTimeout(checkTimeOut, 1000); // Here we check once per second but you change how you wish
    }
}

I hope this will help you

Afsun Khammadli
  • 2,048
  • 4
  • 18
  • 28