Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Show pdf from servlet

 
Ajith George
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Purushoth Thambu
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic