title: What is wrong with XMLHttpRequest request?
body: <p>I am using XMLHttpRequest to create a simple form submitand get session variable from the servlet. But nothing seems to work. Can somebody point out where am I going wrong?</p>
  
  <p>Here is the Form</p>
  
  <pre><code>&lt;form method="post" target="_self" action="/temp/Welcome.html"&gt;
      &lt;table&gt;
          &lt;tr&gt;
              &lt;td&gt;Email&lt;/td&gt;
              &lt;td&gt;&lt;input type="text" id="email" name="email" value="a@a.com"&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Project ID&lt;/td&gt;
              &lt;td&gt;&lt;input type="text" id="projectid" name="projectid" value="1111"&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td colspan="2" align="right"&gt;&lt;input type="button" id="submitbutton" value="Submit" onclick="submitLogin()"&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>here is the submitLogin function</p>
  
  <pre><code>function submitLogin()
  {
   var url_action="/temp/Login";
   var client; 
   var dataString;
   if (client.XMLHttpRequest){ // IE7+, Firefox, Chrome, Opera, Safari
       client=new XMLHttpRequest();
   } else {                    // IE6, IE5
       client=new ActiveXObject("Microsoft.XMLHTTP");
   }
  
   client.onreadystatechange=function(){
       alert(client.responseText);
       if(client.readyState==4&amp;&amp;client.status==200)
       {
           alert(client.responseText);
       }
       else
           alert("Error: return status code "+client.status+" "+client.statusText);
   };
   dataString="email="+document.getElementById("email").value;
   client.open("POST",url_action,true);
   client.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  
   client.send(dataString);
  }
  </code></pre>
  
  <p>and my post method in Login.java servlet</p>
  
  <pre><code>protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
      // TODO Auto-generated method stub
      PrintWriter out = response.getWriter();
      response.setContentType("text/plain");
  
      paramMap=request.getParameterMap();
      if (paramMap == null)
          throw new ServletException(
            "getParameterMap returned null in: " + getClass().getName());
  
      iterator=paramMap.entrySet().iterator();
      //System.out.println(paramMap.size());
      String str="";
  
      while(iterator.hasNext())
      {
          Map.Entry me=(Map.Entry)iterator.next();
          String[] arr=(String[])me.getValue();
          emailId=arr[0];
          //System.out.println(me.getKey()+" &gt; "+emailId);
  
      }
      rand=new Random();
      randomInt=rand.nextInt(1000000);
      emailId=randomInt+emailId;
      System.out.println(emailId);
      out.println(emailId);
  
      /*creates a new session if a session does not exist already*/
      session=request.getSession();
      session.setAttribute("uid", emailId);
  
      out.close();
  }
  </code></pre>
  
  <p>None of the alerts and the System.out seems to show any response. please guide me. Thanks</p>
  
  <p>Note: in IE 8 it shows xmlhttprequest is null or not an object, login.js at Line no: 9</p>