i want to send data from html page to the servlet, i use jquery and a post request, the error is :Failed to load resource: the server responded with a status of 404 (Not Found),i tried to change the url in the post request but i had the same error.
index.html
<body>
<form id="form">
<p><input type="text" id="name"></p>
<p> <input type="button" value="test servlet" id="test" ></p>
<div id="res"></div>
</form></body>
test.js
$("#test").click(function (){
var n = $("#name").val();
$.post("controller/Test.java",{name:n},function(data){
$("#res").html(data);
});
package:controller,Test.java
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
PrintWriter out = response.getWriter();
String a ;
a = request.getParameter("name");
out.println("welcome" +a);
}
thanks