title: Ajax responseText not being displayed
body: <p>I have written an Ajax script in "home.jsp" page which delegates the request object to "like.jsp" page which then calls a servlet method returning boolean value.
  I am trying to display this boolean value in an html element(&lt;'span'> tag).
  Here is the Ajax script:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      function like()
      {
          alert('g');
          var i = "a1eec";
          var xmlhttp;    
          if (window.XMLHttpRequest)
            {// code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp=new XMLHttpRequest();
            }
          else
            {// code for IE6, IE5
            xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
            }
  
          try{  
              xmlhttp.onreadystatechange=getInfo;  
              xmlhttp.open("GET","like.jsp?q="+i,true);  
              xmlhttp.send();  
              }
          catch(e){
              alert("Unable to connect to server");
          }  
      }  
  
  
      function getInfo(){ 
  
          if(xmlhttp.readyState==4){
              //alert('p');
              var val=xmlhttp.responseText;  
              document.getElementById("flike").innerHTML=val;  
          }
          else if(xmlhttp.readyState!=4)
          {
              //alert('t');
              document.getElementById("flike").innerHTML=val;  
          }
      }
  </code></pre>
  
  <p></p>
  
  <p>The like.jsp page code:</p>
  
  <pre><code>&lt;body&gt;
  &lt;%  
      System.out.print("IT IS LIKE&gt;JSP");
      String name = (String)session.getAttribute("email");
      String text_id = request.getParameter("q");
      boolean flag = service1.likes(text_id, name);
  
      if(flag)
          out.print(flag);
      else
          System.out.println("Not");
  
      //response.sendRedirect("home.jsp");
  %&gt;
  </code></pre>
  
  <p></p>
  
  <p>The var '<strong>val</strong>''s value is not being displayed in desired element.
  I have tested servlet and like.jsp page giving manual input and there is no problem but just in case you notice anything going wrong. </p>
  
  <p>Thanks in advance!</p>