title: Get plain text from XMLHttpRequest responseText
body: <p>Can anyone please tell me how to extract a String returned by Struts action class from AJAX reponse? Below is my code snippet:</p>
  
  <p><strong>JS call</strong>:</p>
  
  <pre><code>    xmlhttp=new XMLHttpRequest();
      xmlhttp.open('POST', 'getMessage.do', false);
      xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      xmlhttp.send();
      alert(xmlhttp.responseText);
  </code></pre>
  
  <p><strong>Struts.xml</strong></p>
  
  <pre><code>    &lt;action name="getMessage" class="SampleAction" method="getMessage"/&gt;
  </code></pre>
  
  <p><strong>Action</strong></p>
  
  <pre><code>    public String getMessage() {
      String msg = null;
      HttpSession hSession = this.request.getSession(false);
      if(null != hSession) {
          if(null != hSession.getAttribute("user")) {
              User user = (User) hSession.getAttribute("user");
              if(null != user.account) {
                  msg =  user.account.getMessage(); //Sample message
              }
          }
      }
      return msg;
  }
  </code></pre>
  
  <p>When I print the response text (using alert), it printed message with all HTML information included. actual message is highlighted in bold</p>
  
  <p><strong>response message</strong></p>
  
  <p>html>head>title>Apache Tomcat/5.0.28 - Error report/title>style>!-- {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}-->/style> /head>body>>HTTP Status 404 - No result defined for action com.sample.SampleAction$$EnhancerByCGLIB$$69b4e30e and result <strong>Sample message</strong>HR size="1" noshade="noshade">p>b>type/b> Status report/p>p>b>message u>No result defined for action com.sample.SampleAction$$EnhancerByCGLIB$$69b4e30e and result <strong>Sample message</strong>/u>/p>p>b>description/b> u>The requested resource (No result defined for action com.sample.SampleAction$$EnhancerByCGLIB$$69b4e30e and result <strong>Sample message</strong>) is not available./u>/p>HR size="1" noshade="noshade">h3>Apache Tomcat/5.0.28/h3>/body>html></p>