title: Exception while using the response outputstream in a Java-backed Alfresco-Share webscript
body: <p><strong>1. Context</strong></p>
  
  <p>I want to implement an Alfresco-Share Java-backed webscript like the existing "I18N resources and messages Web Script".
  The main difference is that I want to use the response outputstream (not the writer).</p>
  
  <p>Alfresco-Share version used: 4.1.1.</p>
  
  <p><strong>2. Test code used to reproduce the error</strong></p>
  
  <p><em>- Spring bean:</em></p>
  
  <pre><code>&lt;bean id="webscript.test.content.get" parent="webscript" class="test.TestWebscript" /&gt;
  </code></pre>
  
  <p><em>- Java code:</em></p>
  
  <pre><code>package test;
  
  import java.io.IOException;
  
  import org.springframework.extensions.webscripts.AbstractWebScript;
  import org.springframework.extensions.webscripts.WebScriptRequest;
  import org.springframework.extensions.webscripts.WebScriptResponse;
  
  public final class TestWebscript extends AbstractWebScript
  {
      @Override
      public void execute(final WebScriptRequest request, final WebScriptResponse response) throws IOException
      {
          response.getOutputStream().write("test".getBytes());
      }
  }
  </code></pre>
  
  <p><em>- Webscript desc file:</em></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;webscript&gt;
    &lt;shortname&gt;Test webscript&lt;/shortname&gt;
    &lt;description&gt;A webscript using the response outputstream&lt;/description&gt;
    &lt;url&gt;/test/content&lt;/url&gt;
    &lt;format default=""&gt;extension&lt;/format&gt;
    &lt;lifecycle&gt;draft_public_api&lt;/lifecycle&gt;
    &lt;authentication&gt;guest&lt;/authentication&gt;
    &lt;transaction&gt;required&lt;/transaction&gt;
    &lt;family&gt;Tests&lt;/family&gt;
  &lt;/webscript&gt;
  </code></pre>
  
  <p><strong>3. Result</strong></p>
  
  <p>I have the exception below:</p>
  
  <pre><code>java.lang.IllegalStateException: getOutputStream() has already been called for this response
      at org.apache.catalina.connector.Response.getWriter(Response.java:611)
      at org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:198)
      at org.springframework.extensions.webscripts.servlet.WebScriptServletResponse.getWriter(WebScriptServletResponse.java:198)
      at org.springframework.extensions.webscripts.LocalWebScriptRuntimeContainer.executeScript(LocalWebScriptRuntimeContainer.java:241)
      at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:377)
      at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:209)
      at org.springframework.extensions.webscripts.servlet.mvc.WebScriptView.renderMergedOutputModel(WebScriptView.java:104)
      at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
      at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1047)
      at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:817)
      at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
      at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
      at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.alfresco.web.site.servlet.MTAuthenticationFilter.doFilter(MTAuthenticationFilter.java:74)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.alfresco.web.site.servlet.SSOAuthenticationFilter.doFilter(SSOAuthenticationFilter.java:355)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
      at org.apache.coyote.http11.Http11NioProcessor.process(Http11NioProcessor.java:886)
      at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:721)
      at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:2256)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
      at java.lang.Thread.run(Thread.java:662)
  </code></pre>
  
  <p><strong>4. Question</strong></p>
  
  <p>Is there any way to use the webscript outputstream response?</p>