title: Ajax response xml is null Java script
body: <p>Servlet response:   </p>
  
  <pre><code>for (int i = 0; i &lt; projNames.size(); i++) {   
      sb.append("&lt;project&gt;");
      sb.append("&lt;projectName&gt;" + projNames.get(i) + "&lt;/projectName&gt;");   
      sb.append("&lt;/project&gt;");
      res.setContentType("text/xml");
      res.setHeader("Cache-Control", "no-cache");
      System.out.println(" test="+test);
      res.getWriter().write(sb.toString());
  }
  </code></pre>
  
  <p>System.out.println shows "sb" value as </p>
  
  <pre><code>&lt;project&gt;&lt;projectName&gt;sample&lt;/projectName&gt;&lt;/project&gt;&lt;project&gt;&lt;projectName&gt;sample 2&lt;/projectName&gt;&lt;/project&gt; 
  </code></pre>
  
  <p>I'm trying to retrieve the response XML and but when I checked the length "object value is null" ( debugged in IE 8 )</p>
  
  <pre><code>function displayValues()
  {
      var response;
      if (req.responseXML != null)
          alert("res xml is ther=="+ response); //displays UNDEFINED
      else
          alert("no res xml");
  
      response = req.responseXML.getElementsByTagName("project")[0];
      alert("child node"+response.childNodes.length); // alert is not displayed
  } 
  </code></pre>
  
  <p>Please enlighten. Thanks</p>
  
  <p>AJAX code:</p>
  
  <pre><code>&lt;SCRIPT type="text/javascript"&gt;
  var response;
  var firstName;
  var icdatevalue;
  function getProject()
  { 
  var url ="DBActionServlet?action=getProject"; 
              initRequest(url);
              req.onreadystatechange = processRequest;
              req.open("POST", url, true); 
              req.send(null);
                  }
  function initRequest(url) 
           {
              if (window.XMLHttpRequest) 
              {
                  req = new XMLHttpRequest();
              } 
              else if (window.ActiveXObject) 
              {
                  isIE = true;
                  req = new ActiveXObject("Microsoft.XMLHTTP");
              }
  
           }
  
          function processRequest() 
           {
              if (req.readyState == 4) 
              {
                  if (req.status == 200) 
              {
  
                      alert("status="+req.status);//status is shown as 200
                      displayValues(); //this function code mentioned above
                  }
              }
           }
  
      &lt;/SCRIPT&gt;
  </code></pre>