admin管理员组文章数量:1344621
To prevent user to go back after logout i used following code in home.jsp
page
<%
if (session.getAttribute("authe") != null && session.getAttribute("authe").equals(true)) {
}
else {
response.sendRedirect("login.jsp");
}
%>
and I invalidated the session in logout.jsp
.
It worked fine but when I pressed back button after logout it still goes to home page but after reloading that home page it moves to the login page. I thought it it due to the browser default action.
How to make it to work effectively?
To prevent user to go back after logout i used following code in home.jsp
page
<%
if (session.getAttribute("authe") != null && session.getAttribute("authe").equals(true)) {
}
else {
response.sendRedirect("login.jsp");
}
%>
and I invalidated the session in logout.jsp
.
It worked fine but when I pressed back button after logout it still goes to home page but after reloading that home page it moves to the login page. I thought it it due to the browser default action.
How to make it to work effectively?
Share Improve this question edited Jul 30, 2017 at 8:30 xlm 7,64415 gold badges58 silver badges60 bronze badges asked Oct 13, 2013 at 16:50 manchumanchu 551 gold badge2 silver badges7 bronze badges 1- Have you ruled out caching? – Brandon Commented Oct 13, 2013 at 17:01
2 Answers
Reset to default 6In home.jsp
put header as no-cache
:
<%
response.addHeader("Cache-Control", "no-cache,no-store,private,must-revalidate,max-stale=0,post-check=0,pre-check=0");
response.addHeader("Pragma", "no-cache");
response.addDateHeader ("Expires", 0);
%>
You can use:
<%
try {
response.setHeader("Cache-Control","no-cache");
response.setHeader("Cache-Control","no-store");
response.setHeader("Pragma","no-cache");
response.setDateHeader ("Expires", 0);
if (session.getAttribute("userid")==null) {
response.sendRediredirect("login.jsp");
}
else {}
}
catch(Exception ex) {
out.println(ex);
}
%>
本文标签: javascriptafter logout do not go back to previous page in jspStack Overflow
版权声明:本文标题:javascript - after logout do not go back to previous page in jsp - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743801997a2541488.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论