Struts 2 Stream result Action

  
  
           
  
  
  1. <action name="text-result" class="actions.TextResult"> 
  2.     <result type="stream"> 
  3.         <param name="contentType">text/html</param> 
  4.         <param name="inputName">inputStream</param> 
  5.     </result> 
  6. </action> 
  
  
           
  
  
  1. package actions; 
  2.  
  3. import java.io.InputStream; 
  4. import java.io.StringBufferInputStream; 
  5. import com.opensymphony.xwork2.ActionSupport; 
  6.  
  7. public class TextResult extends ActionSupport  { 
  8.     private InputStream inputStream; 
  9.     public InputStream getInputStream() { 
  10.         return inputStream; 
  11.     } 
  12.  
  13.     public String execute() throws Exception { 
  14.         inputStream = new StringBufferInputStream("Hello World! This is a text string response from a Struts 2 Action."); 
  15.         return SUCCESS; 
  16.     }