I am submitting my form page and on successful insertion into DB, it is redirected to success page. When I click back button from success page,it comes back to form page with populating old values in respective fields. How can I reload the same success page restricting the browser to go back to previous page.
-
2Possible duplicate of [Disable browser's back button](http://stackoverflow.com/questions/961188/disable-browsers-back-button) – Jordi Castilla Apr 27 '16 at 11:22
6 Answers
When u use back button or link?
I think u should use button for back button?
use Response.sendRedirect(theFirstPageURL);
in servlet.

- 2,242
- 2
- 13
- 27
Try this: <a href="javascript:history.go(0)">Click to refresh the page</a>
or you could use this in your html header if you're ok with no caching at all:
<meta http-equiv="cache-control" content="no-cache">

- 308
- 1
- 16
after successful submission , reset the form (using jquery or javascript). so that you cannot see the old values.

- 1
- 3
use:
String s = request.getRequestURL();
to get the current page url
and then use the form for your submit button and pass the param 's' in your form action
<form action="<%=s%>"</form>

- 821
- 3
- 14
- 35
You cant control browser's back button because it fetch value from cache storage of browser. Yes you can stop back button url for that you have to set no cache in response type of servlet and you have to change configuration file and add interceptor so that when that url fires interceptor detect that url and reload your current page.
You can stop caching of you jsp page by adding this line in your servlet from where jsp is called:
response.setHeader("Cache-Control", "private, no-store, no-cache,must-revalidate");
response.setHeader("Pragma", "no-cache");

- 361
- 2
- 13
You just need to autocomplete="off" into your Form-Tag.
Like this:-
<form class="form-horizontal" method="post" enctype="multipart/form-data" id="Nform" autocomplete="off">

- 129
- 1
- 6