Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Dez Max
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
response.setContentType("application/pdf");
 
Dez Max
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic