How can reach a JavaServlet from JavaScript?
My html-File in the path P08_BillBoard/web/billboard.html
. Addtionally, the billboard.js
is in the same directory.
The servlet-File is in P08_BillBoard/src/java/de/vs/Billboard.java
.
Now, if I try to run the application, I get the following error from the browser:
POSThttp://localhost:63342/P08_BillBoard/web/BillBoardServer
404 Not Found
The code of the POST-Request in the billboard.js is:
function postHttpRequest(url) {
var xmlhttp = getXMLHttpRequest();
xmlhttp.open("POST", url, true);
xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlhttp.onreadystatechange = function() {
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
getHttpRequest(url);
document.getElementById("something").value = "";
}
};
xmlhttp.send("value="+document.getElementById("something").value);
}
I guess the problem is the path, but how looks the modification of the code?