title: jsp - execute java function through onsubmit
body: <p>I have this jsp page - </p>
  
  <pre><code>&lt;%@page import="java.text.Normalizer.Form"%&gt;    
      &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
      &lt;html&gt;
      &lt;head&gt;
      &lt;/head&gt;
      &lt;body&gt;
  
          &lt;legend&gt;Create new customer&lt;/legend&gt;
            &lt;%!
          boolean checkForm(Form theForm)
          {
            // some checks on "theForm" .. 
            return false ; 
          }
          %&gt;
          &lt;form action="CreateCustomerServlet" method="GET" onsubmit=&lt;%=checkForm() %&gt;&gt;
              // form's fields .. 
              &lt;input type="submit" value="Create customer" /&gt;
          &lt;/form&gt;
          &lt;/fieldset&gt;
      &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>
  
  <p>What I trying to do is when press on <code>submit</code> it will go to the <code>checkForm</code> function and check the form , and only if <code>checkForm</code> returned <code>true</code> it will go <code>CreateCustomerServlet</code> servlet . </p>
  
  <p>But when I run on server this page and press on <code>submit</code> button I see that it's ignore from the<code>checkForm</code> and directly go to <code>CreateCustomerServlet</code> servlet . </p>
  
  <p>I know that to this with javascript is very easy  .. but I want to do it with java function .</p>