I've been searching for a solution to a problem I am having with forwarding PDF output to the user. I am using exact code from another application that uses JRun. What happens is a new window is opened and I receive a File Download prompt. No matter what option I select, the process fails. I've tried this in IE 6.0 and Netscape 7.1 and Netscape works - the new window displays the generated pdf. Here's the code:
In execute() method:
I use iText to generate the PDF and it takes in a Document and an OutputStream. This code works in a production environment using JRun instead of Tomcat and Struts. This also works flawlessly under Netscape 7.1, but IE 6.0 is the only supported browser in our company.
Does anyone have any idea why this isn't working in IE? I've tried various versions of this code, including reading a pdf file instead of writing from an output stream. I've also tried setting the header on the response using this code:
Thanks,
Patrick Dezenzio
In execute() method:
Code:
ByteArrayOutputStream bos = new ByteArrayOutputStream(5000);
//Obtain the BLOB from the database and generate a PDF
PDFiText report = new PDFiText(selectText(passedGENLTRID), bos);
httpServletResponse.setContentType("application/pdf");
httpServletResponse.setContentLength(bos.size());
OutputStream os = httpServletResponse.getOutputStream();
os.write(bos.toByteArray(), 0, bos.size());
os.flush();
os.close();
return null;
Does anyone have any idea why this isn't working in IE? I've tried various versions of this code, including reading a pdf file instead of writing from an output stream. I've also tried setting the header on the response using this code:
Code:
httpServletResponse.setHeader("Content-Disposition","attachment; filename=somefilename.pdf");
Patrick Dezenzio