title: stay in the current page after clicking cancel button
body: <p>I have a form in index.jsp and after clicking submit i am showing an alert "confirm submit?" if <em>ok</em> will be clicked then confirmsubmit.jsp will be displayed. I am getting text box name in  confirmsubmit.jsp by <code>request.getParameter("textboxname");</code>But problem is if I click <em>cancel</em> then also confirmsubmit.jsp is opening, how can I stay in index.jsp after clicking cancel button in alert?</p>
  
  <p>Any help please</p>
  
  <p>index.jsp</p>
  
  <pre><code>&lt;form action="confirmsubmit.jsp" method="POST"&gt;
  &lt;script type="text/javascript"&gt;
  &lt;!--
  function confirmation() {
  var answer = confirm("Confirm submit?")
  if (answer){
  
      window.location = "confirmsubmit.jsp";// goes to confirmsubmit.jsp
  }
  else{
      //should remain in index.jsp but here also confirmsubmit.jsp is opening
  }
  }
  //--&gt;
  &lt;/script&gt;
  &lt;input type="text" name="textboxname"/&gt;
  &lt;input type="submit" onclick="confirmation()"/&gt; 
  &lt;/form&gt; 
  </code></pre>