struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Moore <j...@jmsd.co.uk>
Subject Forward after returning content?
Date Tue, 11 May 2004 17:01:00 GMT
 I suppose what I am trying to do is impossible, but I just wanted to 
make sure. I have a link where people can download a file, which is 
handled by a DownloadAction. Below is the relevant code to download the 
file, from the execute method. What I want to have happen is that, when 
the file is downloaded, that they should be forwarded to a page 
explaining what to do with the downloaded file. In my code here, that 
would be dealt with by the last line. The problem is that it never 
actually does get forwarded to the page, presumably because the request 
is by this point deemed to have been fully dealt with (i.e., the 
response has been returned). How should I go about doing this?

                   res.setStatus(res.SC_OK);
                    res.setContentType("application/octet-stream");
                    res.setHeader("Content-Disposition", "attachment; 
filename=" + file.getName());
                    res.setContentLength((int)file.length());
                    BufferedOutputStream bos=new 
BufferedOutputStream(res.getOutputStream());
                    BufferedInputStream bis=new BufferedInputStream(new 
FileInputStream(file));
                    byte[] buf=new byte[32768];//do it in large chunks, 
it's quicker
                    int bytesRead;
                    while((bytesRead=bis.read(buf,0,buf.length))!=-1) {
                        bos.write(buf,0,bytesRead);
                    }
                    bos.close();
                    bis.close();
                    saveInfo(downloadForm); //save the details in the 
database
                    forward=mapping.findForward("success");

John

=============================================
John Moore     -    Norwich, UK    -    john@jmsd.co.uk
=============================================

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


Mime
View raw message