You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "Sasidhar.av" <sa...@gmail.com> on 2008/09/25 08:55:26 UTC

java.lang.IllegalStateException while filedownloading program in Tapestry4.1.6

Hai,

 I am writing file downloading program (zip file) ,but i am getting the
exception IllegalStateException i,e (getWriter() has already been called for
this response).

this is sample code.

@InjectObject("service:tapestry.globals.HttpServletResponse")
  public abstract HttpServletResponse getHttpResponse();

 public void pageBeginRender(PageEvent pPageEvent)
  {
    HttpServletResponse httpServletResponse=getHttpResponse();

       InputStream fis = null;
      try
      {
        File f =new File("d:\sample.zip");
        httpServletResponse.setContentType("application/zip");
        httpServletResponse.setContentLength((int) f.length());
        httpServletResponse.setHeader("Content-Disposition", "attachment;
filename="
            + f.getName());
       ServletOutputStream servletOut
=(ServletOutputStream)httpServletResponse.getOutputStream();
        int read = -1;
        fis = new FileInputStream(f);
        byte b[] = new byte[fis.available()];
        read = fis.read(b);
        while (read != -1)
        {
          servletOut.write(b, 0, read);
          read = fis.read(b);
        }
        servletOut.flush();
      }
      catch (Exception e)
      {
        e.printStackTrace();
      }
}

Can u please help me out this problem.

In console i am getting that :

 java.lang.IllegalStateException: getWriter() has already been called for
this response
12:01:31,988 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
org.apache.catalina.connector.Response.getOutputStream(Response.java:565)
12:01:31,988 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
org.apache.catalina.connector.ResponseFacade.getOutputStream(ResponseFacade.java:171)
12:01:31,988 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
com.ingenix.freya.web.pages.rulesmanagement.SaveExportRules.pageBeginRender(SaveExportRules.java:48)
12:01:31,988 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
org.apache.tapestry.AbstractPage.firePageBeginRender(AbstractPage.java:409)
12:01:31,988 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
org.apache.tapestry.AbstractPage.renderPage(AbstractPage.java:244)
12:01:31,988 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
org.apache.tapestry.engine.RequestCycle.renderPage(RequestCycle.java:397)
12:01:31,988 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
org.apache.tapestry.services.impl.DefaultResponseBuilder.renderResponse(DefaultResponseBuilder.java:151)
12:01:31,988 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
org.apache.tapestry.services.impl.ResponseRendererImpl.renderResponse(ResponseRendererImpl.java:33)
12:01:32,019 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
$ResponseRenderer_11c98278a7d.renderResponse($ResponseRenderer_11c98278a7d.java)
12:01:32,019 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
org.apache.tapestry.engine.DirectService.service(DirectService.java:147)
12:01:32,019 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
$IEngineService_11c98278aee.service($IEngineService_11c98278aee.java)
12:01:32,019 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
org.apache.tapestry.services.impl.EngineServiceOuterProxy.service(EngineServiceOuterProxy.java:72)
12:01:32,019 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
org.apache.tapestry.engine.AbstractEngine.service(AbstractEngine.java:241)
12:01:32,019 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
org.apache.tapestry.services.impl.InvokeEngineTerminator.service(InvokeEngineTerminator.java:54)
12:01:32,019 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
$WebRequestServicer_11c98278ac7.service($WebRequestServicer_11c98278ac7.java)
12:01:32,019 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
$WebRequestServicer_11c98278ac3.service($WebRequestServicer_11c98278ac3.java)
12:01:32,019 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
org.apache.tapestry.services.impl.WebRequestServicerPipelineBridge.service(WebRequestServicerPipelineBridge.java:61)
12:01:32,019 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
$ServletRequestServicer_11c98278aa9.service($ServletRequestServicer_11c98278aa9.java)
12:01:32,019 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
org.apache.tapestry.request.DecodedRequestInjector.service(DecodedRequestInjector.java:55)
12:01:32,019 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
$ServletRequestServicerFilter_11c98278aa5.service($ServletRequestServicerFilter_11c98278aa5.java)
12:01:32,019 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
$ServletRequestServicer_11c98278aab.service($ServletRequestServicer_11c98278aab.java)
12:01:32,019 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
org.apache.tapestry.multipart.MultipartDecoderFilter.service(MultipartDecoderFilter.java:52)
12:01:32,019 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
$ServletRequestServicerFilter_11c98278aa3.service($ServletRequestServicerFilter_11c98278aa3.java)
12:01:32,019 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
$ServletRequestServicer_11c98278aab.service($ServletRequestServicer_11c98278aab.java)
12:01:32,019 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
org.apache.tapestry.services.impl.SetupRequestEncoding.service(SetupRequestEncoding.java:53)
12:01:32,019 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
$ServletRequestServicerFilter_11c98278aa7.service($ServletRequestServicerFilter_11c98278aa7.java)
12:01:32,019 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
$ServletRequestServicer_11c98278aab.service($ServletRequestServicer_11c98278aab.java)
12:01:32,019 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
$ServletRequestServicer_11c98278a9d.service($ServletRequestServicer_11c98278a9d.java)
12:01:32,019 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
org.apache.tapestry.ApplicationServlet.doService(ApplicationServlet.java:126)
12:01:32,019 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
org.apache.tapestry.ApplicationServlet.doPost(ApplicationServlet.java:171)
12:01:32,019 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
12:01:32,019 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
12:01:32,019 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
12:01:32,019 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
12:01:32,019 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
com.ingenix.freya.rulesdeployment.util.CredentialFilter.doFilter(CredentialFilter.java:38)
12:01:32,019 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
12:01:32,019 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
12:01:32,019 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
12:01:32,019 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
12:01:32,019 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
12:01:32,019 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
12:01:32,019 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
12:01:32,019 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
12:01:32,019 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
12:01:32,019 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:482)
12:01:32,019 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
12:01:32,019 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
12:01:32,019 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
12:01:32,019 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
org.josso.tc55.agent.SSOAgentValve.invoke(SSOAgentValve.java:730)
12:01:32,019 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
12:01:32,019 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
12:01:32,019 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
12:01:32,019 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
12:01:32,019 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
12:01:32,019 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
12:01:32,019 INFO  (http-0.0.0.0-8080-6) [STDOUT] 	at
java.lang.Thread.run(Thread.java:595)
     






-- 
View this message in context: http://www.nabble.com/java.lang.IllegalStateException-while-filedownloading-program-in-Tapestry4.1.6-tp19664023p19664023.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org