title: HTML form is resubmitted when user refreshes page - how do I stop this from happening?
body: <p>After a user submits an html form (with method="post") it brings them back to the page they were on (but with some of the data changed). If the user refreshes the page, the form is submitted again. In my application this can create an illegal state (since the form data is submitted without going through verification).</p>
  
  <p>How can I prevent the form from being submitted when the user refreshes the page?</p>
  
  <p>Here is some sample code to give you a basic idea of what is going on:</p>
  
  <pre><code>&lt;script type="javascript"&gt;
  function verifyForm() {
  //do stuff
  }
  ...
  &lt;form onsubmit="return verifyForm();" method="post"&gt;
  &lt;input name="testing" type="text" size="8" /&gt;
  &lt;input name="save" type="submit value="Submit Form" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Then in the JSP controller:</p>
  
  <pre><code>public class myController implements Controller
  { 
  @Override
  public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception
  {
  // do stuff with the form data received in the request
  }
  }
  </code></pre>
  
  <p>There are several places I might be able to solve this problem: in the html page itself, or in the controller (using MVC pattern in jsp). So far I have found <a href="https://stackoverflow.com/questions/9220942/why-a-form-would-automatically-resubmitted-when-the-page-is-refreshed">this question</a> that almost seems to apply to my question, but doesn't quite seem to be asking the same thing (also I am not using PHP).</p>