title: Calling a Java Function From JavaScript Code?
body: <p>Ok, maybe this is a very common question, but I can't find a right answer... <br>
  I have a function in Java (actually, is a Servlet) and what I need/trying to do is this: <br>
  After doing some things, I need to show a "confirm" window, before doing some other things in my code... I'm doing this through javascript, of this way: <br></p>
  
  <pre><code>out.println("&lt;script type='text/javascript'&gt;");
  out.println("result = confirm(Do you wanna to record in DB?)");
  out.println("if(result)");
  out.println("  alert('will record');");
  out.println("else");
  out.println("  alert('will not record')");
  out.println("&lt;/script&gt;");
  out.flush();
  </code></pre>
  
  <p>But the lines that come after of that code, are executed before that my dialog message is displayed. So, now I want to call different functions (where I have alert). Functions inside my Java class/servlet... <br>
  So... How can I call a Java function inside my javascript code? Or what I need to do to make my code wait until I confirm my message? <br>
  Thank you</p>