防止用户在jsp中注销后返回 [英] Preventing User to go back after logout in jsp

查看:364
本文介绍了防止用户在jsp中注销后返回的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

防止用户在注销后返回上一个安全页面

我需要通过阻止用户在注销后访问相同内容来保护java应用程序(mvc)。

I need to secure a java application(mvc) by preventing a user to access the same after signout.

目标:

1.注销后,用户不能使用浏览器后退按钮访问受限页面。
2.注册后,用户不应该能够访问浏览器历史记录中的任何受限制的URL

1.Enduser should not be able to access the restricted page using browser back button after signout. 2.Enduser should not be able to access any restricted URL in browser history after signout

谷歌搜索后,我明白禁用该功能不是一个好习惯浏览器返回按钮。那我怎样才能在JSP中达到最佳效果?

After googling i understood that it is not a good practice to disable the browser-back button.So How can I achieve this at the best in JSP ?

谢谢和问候
Ashish

Thanks&Regards Ashish

推荐答案

在每个页面中,您可以清除缓存页面

In each page you can probably clear the cached page.

  <%
  response.setHeader("Cache-Control","no-cache");
  response.setHeader("Cache-Control","no-store");
  response.setHeader("Pragma","no-cache");
  response.setDateHeader ("Expires", 0);

  if(session.getAttribute("some_token")==null)
      response.sendRedirect("login/login.html");

  %> 

退出中,您必须使会话无效当你点击它时会检查 session 中的 some_token 属性值,如果没有,它会将你重定向到登录页面。但请记住,在登录后,您将在会话中设置 some_token 属性。

In logout you must be invalidating session so when you click back it would check the some_token attribute value in session and if not there it will redirect you to login page . But remember after login you are setting some_token attribute in session.

这篇关于防止用户在jsp中注销后返回的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆