Menu

Exporting: java.io.IOException: Stream closed

Help
James
2005-12-14
2012-10-09
  • James

    James - 2005-12-14

    I'm trying to get the exporting working. I'm using Struts and Tiles. I've followed the instructions at http://displaytag.sourceforge.net/export_filter.html

    I have put the <%@ page buffer = "16kb" %> on both the jsp tile and in the jsp layout.

    I have also put the following into the web.xml

    <filter><filter-name>ResponseOverrideFilter</filter-name><filter-class>org.displaytag.filter.ResponseOverrideFilter</filter-class></filter>
    <filter-mapping>
    <filter-name>ResponseOverrideFilter</filter-name>
    <url-pattern>.do</url-pattern>
    </filter-mapping>
    <filter-mapping>
    <filter-name>ResponseOverrideFilter</filter-name>
    <url-pattern>
    .jsp</url-pattern>
    </filter-mapping>

    However, I still get an exception:

    Has anyone seen this before? How should this be configured?

    Thanks for any help.
    James.

    Exception:

    java.io.IOException: Stream closed at org.apache.jasper.runtime.JspWriterImpl.ensureOpen(JspWriterImpl.java:203) at org.apache.jasper.runtime.JspWriterImpl.clearBuffer(JspWriterImpl.java:159) at org.apache.jsp.layouts.desktopStandard_jsp._jspService(org.apache.jsp.layouts.desktopStandard_jsp:297) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672) at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463) at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398) at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301) at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1056) at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:261) at org.apache.struts.tiles.TilesRequestProcessor.processTilesDefinition(TilesRequestProcessor.java:237) at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:300) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:231) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164) at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:397) at javax.servlet.http.HttpServlet.service(HttpServlet.java:689) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:167) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:172) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.displaytag.filter.ResponseOverrideFilter.doFilter(ResponseOverrideFilter.java:140) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684) at java.lang.Thread.run(Thread.java:595)

     
    • Esteve Olm

      Esteve Olm - 2006-02-20

      From Struts-Tiles API docs:
      flush
      True or false. If true, current page out stream is flushed before insertion.

      It doesn't say anything about flushing the buffer AFTER the insertion, I've tested with my friend debugger and just after the tiles:insert tag, the buffer is flushed. There's no way to avoid it, I've tried increasing buffer and using page directive <%@ page autoFlush="false" %>

       
    • Esteve Olm

      Esteve Olm - 2006-02-06

      I had the same problem.
      At the moment I have not found the solution, but the cause is:

      In my tiles-defs.xml there is one definition including a "reentrant call" to another action, like this:

      <definition name="base.page" path="/main.jsp">
      <put name="header" value="/header.jsp"/>
      <put name="summary" value="summary.do"/>
      <put name="leftMenu" value="/leftMenu.jsp"/>
      <put name="footer" value="/footer.jsp"/>
      </definition>

      I think that calling summary.do causes JSPWriter to close the stream. If you change this put action for a simple jsp, it works.

      I will investigate.

      Esteve

       
      • JonnyBlade

        JonnyBlade - 2006-02-15

        It looks like this issue is brought on by the combination of wrapping the ServletResponse in a displaytag.filter.BufferedResponseWrapper(ResponseOverrideFilter) and using a <jsp:include path='url.do' flush='true' /> in the requested page.
        I haven't had time to fully investigate, but the short answer is merely remove " flush='true' " (flush='false' is appearently not supported) from any jsp:includes on the page or any included pages.

        I have not verified, but setting the tiles:insert flush attribute should work as well :
        <tiles:insert defintion="MyTilesDef" flush="false" />

        ref:
        <jsp:include>
        flush attribute (from spec):
        "The flush attribute controls flushing. If true, then, if the page output is buffered
        and the flush attribute is given a true value, then the buffer is flushed prior to the
        inclusion, otherwise the buffer is not flushed. The default value for the flush
        attribute is false."

        Displaytag 1.1 seems to use the same code;
        Does anyone have any insight to the advantages/disadvatages of setting flush='true',
        as most examples ect. seem to set flush to true.

         
    • Esteve Olm

      Esteve Olm - 2006-02-20

      There must be something, I don't know where, that causes the output to be flushed.
      I cannot make it work neither with tiles:insert nor with jsp:include. Setting flush parameter true, false or without it causes no difference.
      Now I'll try to convert my action to a full JSP, getting all values directly in JSP code. I think that it will be the only way to work.

       

Log in to post a comment.