Thank you in advance. I am calling the servlet using ajax.I am not able to get response from servlet in script. my jsp file looks like this
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
 pageEncoding="ISO-8859-1"%>
 <html>
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
 <title>Insert title here</title>
 <script >
 function makeRequest()
 {
      var xmlhttp;
      if (window.XMLHttpRequest)
      {// code for IE7+, Firefox, Chrome, Opera, Safarixmlhttp=new XMLHttpRequest();
      }
      else
      {// code for IE6, IE5
           xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
      xmlhttp.onreadystatechange=function()
      {  
     if (xmlhttp.readyState==4 && xmlhttp.status==200)
      {
          var val =document.getElementById("t1").value;
          alert(xmlhttp.status);
          alert(xmlHttpRequest.responseText);
          document.getElementById("mydiv").value=xmlHttpRequest.responseText;
      }
  };
  /*xmlhttp.open('GET','http://localhost:7001/ajaxx/f1',true); */
   xmlhttp.open('GET','f1.java',true); 
  xmlhttp.send();
  }
  </script>
  </head>
  <body>
  <form name="f">
  <p> Enter the name </p>
  Name:<input type="text" id="t1"> <br/>
  <input type="button" name="b1" value=" CLICK TO CONECT TO SERVER" onclick=makeRequest()>
  <br/> 
  <div id="myDiv"><h2> AJAX </h2></div>
  </form>
  </body>
  </html>
My servelet file(f1.java) looks like this
  package ajaxx;
  import java.io.IOException;
  import java.io.PrintWriter;
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  public class f1 extends HttpServlet {
  private static final long serialVersionUID = 1L;
  public f1()
  {
     super();
    // TODO Auto-generated constructor stub
  }
   public void doGet(HttpServletRequest request, HttpServletResponse response) throws                            
   {
    System.out.println("hello"); 
    // TODO Auto-generated method stub
    response.setContentType("text/html");
    PrintWriter pw=response.getWriter();
    response.setCharacterEncoding("UTF-8");
    pw.write("Welcome");
    }
    }
Please help me. i am not able to invoke servlet.
 
     
    