aspose file tools*
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 Java 8 in Action this week in the Java 8 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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to respond to the client in PDF format to the client from Servlet?
 
Similar Threads
How to Read PDF files
TRANSFORMING XML TO OTHER FORMATS
Client status update after PDF generation through servlet.
PDF plugin problem
Client status update after PDF generation through servlet.