title: Call a Struts 2 action using ajax, which write a string directly to the response does not return the string
body: <p>In a struts2 application I am calling a Ajax request in and write a string directly to the response as below and return <code>null</code> in the execute method of the action.</p>
  
  <pre><code>ServeletActionContext.getResponse().getOutputStream().print("sample string");
  return null;
  </code></pre>
  
  <p>In <code>struts.xml</code> I have the below declaration, (below is how the application declares the actions with result types which are working fine. In my case since I don't need result to invoke a JSP or another action, I did not add the result tag)</p>
  
  <pre><code>&lt;action name="controller" class="controller"&gt;
  </code></pre>
  
  <p>And I map the section class in the <code>application-context.xml</code></p>
  
  <pre><code>&lt;bean id="controller" class="com.test.ControllerAction" scope="prototype"&gt;
  </code></pre>
  
  <p>Then I have the ajax call as below,</p>
  
  <pre><code>$.ajax({url:"/root/me/controller.action",success:function(result){
      alert(result);
  }});
  </code></pre>
  
  <p>But the problem is in above instead of alerting the <code>"sample string"</code> which I wrote for the response, it alerts the whole JSP page where the above Ajax call resides. What am I  missing here?</p>