0

(Disabling back button in JSP after logging in?)

What does this code mean? Anyone pls explain this following code.Because, I never studied about this 'response.setHeader' method.

<%
response.setHeader("Cache-Control","no-store");
response.setHeader("Pragma","no-cache"); 
response.setHeader ("Expires", "0"); //prevents caching at the proxy server
%>

or any other methods are available for disabling back button in JSP after Logging in?

CodingGeek
  • 1
  • 1
  • 3
  • Check http://docs.oracle.com/javaee/7/api/javax/servlet/http/HttpServletResponse.html#setHeader(java.lang.String, java.lang.String) For ```response.setHeader()``` – seenukarthi Oct 14 '14 at 12:12

3 Answers3

1

If you want to restrict the user to go back then try this small script.

<script>
    history.forward();
</script>

Put this code into the <head> element of your page and try to go back. For more details click on following link...

How to disable browser back button after logout in JSP?

Community
  • 1
  • 1
User
  • 4,023
  • 4
  • 37
  • 63
0

This code sets response headers. Headers is http feature, http://en.wikipedia.org/wiki/List_of_HTTP_header_fields This code just works this in Java.

Boris
  • 1,054
  • 1
  • 13
  • 23
  • Thank u, Any other methods are available for disabling back button in JSP? I urgently need it.Pls, help me out... – CodingGeek Oct 14 '14 at 12:19
  • **disabling back button in JSP** - I don't understand what do you mean. – Boris Oct 14 '14 at 12:22
  • 1. JSP absolutely cannot do this, browser history is clien code task. – Boris Oct 14 '14 at 12:26
  • After logging in into some page, for example, like banking or any other transactions, u can't go back to the previous page. For disabling that back button property I am asking.. – CodingGeek Oct 14 '14 at 12:26
  • That is why, I am asking any other methods are available or not. Can we do that in Javascript? – CodingGeek Oct 14 '14 at 12:27
0

You can do this using JavaScript, for example by asking user not to go away from the page.

window.onbeforeunload = function() { return "You work will be lost."; };
Boris
  • 1,054
  • 1
  • 13
  • 23