• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

PDF and servlets

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everybody,

I am experencing strange problems in connection with a servlet sending a dynamically rendered PDF-file to Firefox and IE-Explorer. The problem is that in IE Explorer the PDF is not displayed inline but instead Acrobat Reader is opened in a seperate window. Whereas in Firefox only the the stream data is displayed as plain text in the browser window.

The servlet answer is processed in the doPost mehtod of the servlet. Basically I followed the suggestions in the various tutorials dealing with servlets/pdfs:

1. The PDf is generated via FOP in a seperate class which returns a ByteArrayOutputStream which is then sent to the client.

doPost method:

...
response.setContentType("application/pdf");
response.setHeader("Content-disposition",
"attachment; filename=Example.pdf" );
ByteArrayOutputStream baos = Xml.makeInvoice(s,b);
response.setContentLength(baos.size());
System.out.print(baos.size());

ServletOutputStream sos;
sos = response.getOutputStream();
baos.writeTo(sos);
sos.flush();
..

Any ideas on what goes wrong?

Thanks
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try:
 
Peter Buchmayer
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ben,

Unfortunetly that change in the coding didn't resolve the issue. It would be great if someone knew some links to servlet / browser related issue. As I assume the issue arises because the resource is not called with the suffix .pdf when the browser sends its request.

Thanks
 
Check your pockets for water buffalo. You might need to use this tiny ad until locate a water buffalo:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!