java 在jsp中注销时禁用后退按钮

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5535107/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 11:34:54  来源:igfitidea点击:

disable back button when logout in jsp

javajspservlets

提问by bhavesh N

I have a jsp page and problem is that when I click the logout button, it redirects to the login page but when press the back button it show the previous pages, so how I can handle it.

我有一个 jsp 页面,问题是当我单击注销按钮时,它会重定向到登录页面,但是当按下后退按钮时,它会显示以前的页面,所以我该如何处理。

采纳答案by trojanfoe

Generate code that uses one of the techniques defined here.

生成使用此处定义的技术之一的代码。

回答by Piyush Chaudhari

if you handle session manually in your application than you remove all session variable from your application and put the following java script in your page  logout page

<SCRIPT type="text/javascript">
    window.history.forward();
    function noBack() { window.history.forward(); }
</SCRIPT>
</HEAD>
<BODY onload="noBack();"
    onpageshow="if (event.persisted) noBack();">

回答by Maran Manisekar

you need to set the response header in the focusing page, (i.e) in the login page. ensure the following code in the login.jsp page,

您需要在聚焦页面中设置响应头,(即)在登录页面中。确保 login.jsp 页面中的以下代码,

Coding:

编码:

response.setHeader("Cache-Control","no-cache");    
response.setHeader("Pragma","no-cache");

/* Note: place this code above any of those code */

/* 注意:将此代码放在任何这些代码之上 */

but i don't know wheather the same functionality can be done using javascript/jquery,"awww... i don't think so!!!"

但我不知道是否可以使用 javascript/jquery 完成相同的功能,“啊……我不这么认为!!!”