You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Hendrickx Wesley <We...@cronos.be> on 2004/02/12 13:26:47 UTC

Problem with opening a file that comes from SevletResponse

Hi,

In my application I have a feature to download a report in PDF format.
The contents come from an XML tree, together with an XSL-T to make the byte array for the PDF file.

The content type for the httpServletOutputStream is as follows:

        httpServletResponse.setContentType("application/pdf");
        httpServletResponse.setHeader("Content-disposition", "attachment; filename=helios.pdf" );

The next thing is stream the pdf to the response of the servlet:

        BufferedOutputStream bos = null;
        ServletOutputStream stream = httpServletResponse.getOutputStream();
        bos = new BufferedOutputStream(stream);
        bos.write(pdf.toByteArray());

Now when i call the action to get the report, everything works fine.
The dialog box to download the file pops up. When I click the save button there is no problem at all -> the file is saved on the HD,
but when i hit the Open button, i get a new dialog box again with open and save buttons.
I hit the open button again, and then I get the error that the file does not exist.


Anyone alse that had this problem and might have come up with a solution to this problem?

Thanks in advance,
Wesley