1 Reply Latest reply on Jul 24, 2007 12:39 PM by ter ron

    D/L file: Servlet response already use stream.

    ter ron Newbie

      Hello,

      while trying to download a file from the backing bean to the client (browser),

      HSSFWorkbook wb = abean.getExpexcel();
      try {
       ServletOutputStream sos = response.getOutputStream();
       wb.write(sos);
       sos.flush();
       } catch (Exception e) {
       System.out.println("Allg. Fehler bei expexcel'ing...");
       e.printStackTrace();
       }
      


      I am getting a

      java.lang.IllegalStateException: Servlet response already use stream, Writer not possible

      at org.ajax4jsf.framework.ajax.xmlfilter.FilterServletResponseWrapper.
      getWriter(FilterServletResponseWrapper.java:226)
      at com.sun.facelets.FaceletViewHandler.
      createResponseWriter(FaceletViewHandler.java:400)
      at com.sun.facelets.FaceletViewHandler.
      renderView(FaceletViewHandler.java:557)
      at org.ajax4jsf.framework.ViewHandlerWrapper.
      renderView(ViewHandlerWrapper.java:108)
      at org.ajax4jsf.framework.ajax.AjaxViewHandler.
      renderView(AjaxViewHandler.java:233)
      at com.sun.faces.lifecycle.RenderResponsePhase.
      execute(RenderResponsePhase.java:106)
      at com.sun.faces.lifecycle.LifecycleImpl.
      phase(LifecycleImpl.java:251)
      at com.sun.faces.lifecycle.LifecycleImpl.
      render(LifecycleImpl.java:144)


      This seems to be related to Ajax4Jsf, since it works without problems in a configuration without Ajax4Jsf + the exception already mention Ajax4Jsf.

      Any way to avoid this error (workaround)?

      Does it have to do with the phase in the lifecycle?
      should I move the excecution to another phase?

      Thanks!