wood burning stoves 2.0*
The moose likes JSP and the fly likes How to respond to the client in PDF format to the client from Servlet? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "How to respond to the client in PDF format to the client from Servlet?" Watch "How to respond to the client in PDF format to the client from Servlet?" New topic
Author

How to respond to the client in PDF format to the client from Servlet?

Dez Max
Ranch Hand

Joined: Oct 01, 2002
Posts: 41
Hi Folks,
Does anybody has code snippets for sending the responds to the client in pdf format from servlets.
As i know , the mime type has to be as application/pdf in the response header but i really don't know how to implement this.
Thanks in advance.
regs
Fred
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
response.setContentType("application/pdf");


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Dez Max
Ranch Hand

Joined: Oct 01, 2002
Posts: 41
Hi,
Thanks for the response. But how do i send the file to the client. Do i have to obtain the outputstream associated with the client and write the raw binary data on the socket connection stream. I've a doubt in this. Could you please clarify me with a sample code if possible.
Thanks in advance.
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Yes, you need to use the OutputStream object available through the HttpServletResponse.
Here's a code example. Note that I haven't compiled it though.
 
Don't get me started about those stupid light bulbs.
 
subject: How to respond to the client in PDF format to the client from Servlet?
 
Similar Threads
PDF plugin problem
TRANSFORMING XML TO OTHER FORMATS
How to Read PDF files
Client status update after PDF generation through servlet.
Client status update after PDF generation through servlet.