Skip to content Skip to sidebar Skip to footer

Call Servlet From Ajax

This is my jsp.. and I use Javascript-function and ajax-call to call servlet (ReadprojectInfo). <%@ page language='java' contentType='text/html; charset=ISO-8859-1' pageEnco

Solution 1:

try commenting out the: xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); and the: if (xmlhttp.status == 200) { ... bits and see if it works


Solution 2:

You have to extend the HttpServlet in your class, like:

public class ReadProjectsInfo extend HttpServlet{
      ...
}

I think you could remove the line:

xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');

It must work...


Solution 3:

give the complete url of the servlet class as below and try once. It worked for me. xmlhttp.open("GET","http://localhost:8080/excelExchange/ReadProjectsInfo",true);


Post a Comment for "Call Servlet From Ajax"