当会话超时然后自动重定向到jsp中的登录页面

时间:2015-06-06 09:18:31

标签: jsp

我想在我所有jsp页面的标题中应用一些代码,它会自动检测会话何时超时并​​重定向到登录页面。

有可能吗?

任何人都有一些想法请告诉我

1 个答案:

答案 0 :(得分:1)

您可以使用JavaScript检查会话超时。请尝试以下方法:

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
    }
}

我希望这会对你有所帮助

相关问题