title: java.lang.IllegalStateException: STREAM when writing excel file as response with Jetty and struts
body: <p>I have a code that creates an excel file using struts and jetty.</p>
  
  <p>In the struts.xml file I declared:</p>
  
  <pre><code>&lt;action name="full-export-excel" method="exportFullDataSetToExcel"
          class="com.me.ExcelAction"&gt;
    &lt;result name="success" type="stream"&gt;
      &lt;param name="contentType"&gt;application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; charset=utf-8
      &lt;/param&gt;
      &lt;param name="inputName"&gt;input&lt;/param&gt;
      &lt;param name="contentLength"&gt;${contentLength}&lt;/param&gt;
      &lt;param name="bufferSize"&gt;1024&lt;/param&gt;
      &lt;param name="contentDisposition"&gt;filename="${fileName}"&lt;/param&gt;
    &lt;/result&gt;
  &lt;/action&gt;
  </code></pre>
  
  <p>In my java code:</p>
  
  <pre><code>final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
  XSSFWorkbook excelWorkBook = excelBuilder.createExcelWorkBook(reportObjects, columnMapper); // My code for creating excel file
  excelWorkBook.write(outputStream);
  input = new ByteArrayInputStream(outputStream.toByteArray());
  </code></pre>
  
  <p>I also have a getter for the content length:</p>
  
  <pre><code>public Integer getContentLength() throws IOException {
    return input.available();
  }
  </code></pre>
  
  <p>This whole code runs under jetty. And when trying to download a large file I get this exception:</p>
  
  <pre><code>Caused by: java.lang.IllegalStateException: STREAM
      at org.eclipse.jetty.server.Response.getWriter(Response.java:944)
      at org.eclipse.jetty.servlets.gzip.CompressedResponseWrapper.getWriter(CompressedResponseWrapper.java:440)
      at javax.servlet.ServletResponseWrapper.getWriter(ServletResponseWrapper.java:152)
  </code></pre>
  
  <p><strong>EDIT:</strong> It works for smaller excel files but not for large ones. I also tried to write the large files to the file-system (to make sure that's not the excel exporting but rather a communication issue) and it worked.</p>