my dog learned polymorphism
The moose likes Servlets and the fly likes Show pdf from servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Show pdf from servlet" Watch "Show pdf from servlet" New topic

Show pdf from servlet

Ajith George
Ranch Hand

Joined: Dec 22, 2005
Posts: 109
As i submit data the response i get from server is in pdf format. i read it using input stream reader and was able to print it on prompt. But what i want is to add it to response and show it as pdf on client machine. ie acrobat reader must pop up and show the data. How can i do that.........Please help me

Thanks in advance.

SCJP 1.4, Brainbench
LinkedIn - Blog
Purushoth Thambu
Ranch Hand

Joined: May 24, 2003
Posts: 425
Ajith, do search this forum for showing PDF. You can try to search with keyword "application/pdf". It would be better if you search the forum before starting the thread.
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42958
This Wiki page talks about how to set the headers for an Excel file; translate that to PDF (for which the content type is application/pdf, I think), and it should work the same.
Vinay Thippeswamy

Joined: Apr 26, 2006
Posts: 15
try this. i dont know it works.


[ June 05, 2006: Message edited by: Vinay Thippeswamy ]
Ajith George
Ranch Hand

Joined: Dec 22, 2005
Posts: 109
Thanks guys. Now it's working. The problem was usage of stream reader. When i changed it to Buffered stream reader it is working.
pawank gupta
Ranch Hand

Joined: Jun 07, 2006
Posts: 34
surely vinay it works because when u declare the response header content type n when u write the output stream on ur response it save the file with given content header which it reads from MIME definition in ur web.xml
I agree. Here's the link:
subject: Show pdf from servlet
It's not a secret anymore!