struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Mitchell" <jmitc...@telocity.com>
Subject RE: IllegalStateException: Cannot forward after response has been committed
Date Wed, 19 Jun 2002 15:30:42 GMT
Did you specify redirect=true for this action?

James Mitchell
Software Engineer\Struts Evangelist
Struts-Atlanta, the "Open Minded Developer Network"
http://struts-atlanta.open-tools.org

> -----Original Message-----
> From: Thinh Doan [mailto:tdoan@twjconsulting.com]
> Sent: Wednesday, June 19, 2002 11:14 AM
> To: Struts-User
> Subject: IllegalStateException: Cannot forward after response has been
> committed
>
>
> I have a download action that generates the above error upon return
> mapping.findForward("success"). I did a search in the mail archive but
> nothing seems to point to a solution.
>
> Here is the code snippet of the download action:
> ...
>         try {
>             response.setContentType("txt");
>             response.setHeader("Content-Disposition",
> "attachment;filename=\"" + filename + "\";");
>
>             BufferedOutputStream bos = new
> BufferedOutputStream(response.getOutputStream());
>             File tmpFile = new File(filetoget);
>             FileInputStream fis = new FileInputStream(tmpFile);
>             byte[] buffer = new byte[1024];
>             int bytes_read;
>             while((bytes_read = fis.read(buffer)) != -1) {
>                 bos.write(buffer, 0, bytes_read);
>             }
>             fis.close();
>             bos.close();
>
>             tmpFile.delete();
>
>         } catch(FileNotFoundException fe) {
>             return mapping.findForward("fail");
>         } catch(IOException io) {
>             return mapping.findForward("fail");
>         }
>         return ( mapping.findForward("success") );
>
>
> Error in tomcat log:
> ...
> 2002-06-17 15:43:20 StandardWrapperValve[action]: Servlet.service() for
> servlet action threw exception
> java.lang.IllegalStateException: Cannot forward after response has been
> committed
> 	at
> org.apache.catalina.core.ApplicationDispatcher.doForward(Applicati
> onDispatch
> er.java:367)
> 	at
> org.apache.catalina.core.ApplicationDispatcher.forward(Application
> Dispatcher
> .java:355)
> 	at
> org.apache.struts.action.ActionServlet.processActionForward(Action
> Servlet.ja
> va:1759)
> 	at
> org.apache.struts.action.ActionServlet.process(ActionServlet.java:1596)
> 	at
> org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:492)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> ...
>
> Please indicate what I did wrong here. TIA for your help.
>
> Thinh
>
>
>
> --
> To unsubscribe, e-mail:
<mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail:
<mailto:struts-user-help@jakarta.apache.org>



--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>


Mime
View raw message