title: How to send simple data from javascript to java application
body: <p>I am trying to send a simple message from javascript. I want to receive the data in a java program (server), but I can't seem to figure out how to obtain the message in java.</p>
  
  <p>Here is my javascript:</p>
  
  <pre><code>   if (window.XMLHttpRequest) {
          xmlhttp = new XMLHttpRequest();
      } else {
          xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } 
      xmlhttp.open("POST", ip, true);
      xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      xmlhttp.send("posX=" + posX + "&amp;posX = " + posX);
  </code></pre>
  
  <p>I have 2 questions regarding this.</p>
  
  <ul>
  <li>Is the above the fastest method to send simple string data from
  javascript to a java program or can you recommend an alternative
  solution?</li>
  <li>How can I receive the above POST request from the javascript with java?</li>
  </ul>
  
  <p>I really hope someone can help me out.
  Any help will be greatly appreciated</p>