2015-06-06 69 views
0

我想要在我的所有jsp頁面的標題中應用一些代碼,它會在會話超時並重定向到登錄頁面時自動檢測。當會話超時,然後自動重定向到jsp登錄頁面

可能嗎?

任何一個有一些想法,請告訴我

+0

你可以做到這一點的JavaScript –

+0

如何。如果任何代碼,請把這裏 – Rohini

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

我希望這將有助於你

+0

好的謝謝。我的問題解決了 – Rohini

相關問題