Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Unable to View PDF in Browser from a Servlet.

843841Feb 10 2006 — edited Dec 28 2006
Hi,
I am facing a problem while trying to dynamically generate PDF from a Servlet and display it in the browser(IE 6.0 sp2)

The scenario is as follows:

i have a link which on clicking (using javascript) moves to a Servlet(say Dispatcher Servlet).This servlet forwards the control to another Servlet(say PDF Renderer Servlet) which generates the PDF and tries to display the results to the browser.
The PDF does get generated.

However in the pop-up i get a alert message to either open or save the PDF.But when i try to do so the message i get is that IE failed to communicate with the server.

The code i am using to display the PDF is as follows
---------------------------------------------------------------------
ByteArrayOutputStream outfile = pdfTransformer.transform(xmlString,container);
byte[] content = outfile.toByteArray();
response.setContentType("application/pdf");
response.setContentLength(content.length);
response.setHeader("Content-Disposition", "inline; filename=\"" + pdfName + "\"");
ServletOutputStream out= response.getOutputStream();
out.write(content);
out.flush();
out.close();
---------------------------------------------------------------------


Any suggestions would be a great help.
Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 25 2007
Added on Feb 10 2006
4 comments
973 views