I am working on one project which has lot pf pages..
My pages structure is as follows: login >> dashboard >> add >> view >> edit and so on... Problem I am facing is : If I clicked back button and I am on login page then again If I have clicked back button it is redirecting to dashboard page again.
What I want is: I want to clear browsers history or it should not go to dashboard page from login page if I pressed back button from login page.
I tried lot of code snippets,all code I have added in login page: Some of them are below:
Javascript code: 1)
var Backlen=history.length;
history.go(-Backlen);
window.location.href=contextPath + "login.jsp";
2)
function preventBack(){window.history.forward();}
setTimeout(preventBack(), 0);
window.onunload=function(){null};
3)
function disableBack() { window.history.forward() }
window.onload = disableBack();
window.onpageshow = function(evt) { if (evt.persisted) disableBack() }
Also tried Java code as well- cleared sessions using below code:
<%
String forwardUrl = "";
if(sessionTimeout!=null)
{
request.setAttribute("timeoutMessage", sessionTimeout);
forwardUrl="login.jsp?locale="+locale+"&timeoutMessage="+sessionTimeout;
}else
{
forwardUrl="login.jsp?locale="+locale;
request.getSession().removeAttribute(sessionTimeout);
}
%>