Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
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
Author

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
Marshal

Joined: Mar 22, 2005
Posts: 41182
    
  45
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.


Ping & DNS - my free Android networking tools app
Vinay Thippeswamy
Greenhorn

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

response.addHeader("content-type","application/pdf");


regards
vinay
[ 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
 
jQuery in Action, 2nd edition
 
subject: Show pdf from servlet
 
Similar Threads
What 5 pieces of software would you take to the fabled "desert island"?
Reading data in a CLOB from BIRT report
How can I close Acrobat Reader when a servlet show a pdf file?
Displaying Clob Data in BIRT report
java program to read data from pdf file