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.
Here is my javascript:
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 + "&posX = " + posX);
I have 2 questions regarding this.
- Is the above the fastest method to send simple string data from javascript to a java program or can you recommend an alternative solution?
- How can I receive the above POST request from the javascript with java?
I really hope someone can help me out. Any help will be greatly appreciated