This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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
Rancher

Joined: Mar 22, 2005
Posts: 42958
    
  73
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
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
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Show pdf from servlet
 
It's not a secret anymore!