CodingGeek
CodingGeek

Reputation: 1

Disabling back button in JSP after logging in?

(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?

Upvotes: 0

Views: 7958

Answers (3)

User
User

Reputation: 4211

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?

Upvotes: 1

Boris
Boris

Reputation: 1136

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."; };

Upvotes: 0

Boris
Boris

Reputation: 1136

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.

Upvotes: 0

Related Questions