Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Open pdf in browser

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
My servlet is sending pdf in the response. I want this pdf to open the pdf in the browser only, instead of opening in the Acrobat reader. Can i control this. Please help me out. Its urgent.

Thanks
Ramdas
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ramdas Sawant
Welcome to JavaRanch!

In an effort to help you get the most from our forums, we've compiled a
list of tips for asking questions here. You can find the list in our
FAQ section here.
In particular, please see EaseUp to find out how adding the word "urgent" to your posts will usually slow down or stop responses.

Again, welcome to JavaRanch and good luck with your question.
-Ben


As to your question:
Browsers can't display PDFs on their own. A PDF viewer (such as Acrobat) is needed. Some browsers can embed Acrobat as a plugin and will appear to display your PDF in the browser.
To do this, you need to add a Content-Dispostion header with the 'inline' keyword.
Search this and the JSP forum with keyword 'Content-Dispostion' for more information.
If you're only providing a link to the PDF (as opposed to streaming it with your own code) you may not be able to control what headers are sent.
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ramdas,
To display the PDF file in your browser you must have any one of the following things..
1) Your Desktop must have the (PDF reader like Acrobat)
other wise
2) Your Browser must have the plug in to display the .PDF files.

okie come to the point .. in your Servlet or JSP .. first you to set the content type as (MIME) txt/pdf and you to read tat stream as well as u have to write it in your page ..
You can get the source code from the "Google" Search.. If u cant get the code please feel free to ask me ..

regards
Ajay Krishnamurthy
 
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

You can also do two things :

1. Use the embed tag
2. Use the object tag

However these two will work only if acrobat plugin is installed.

Bye & Regards,

Praveen
 
reply
    Bookmark Topic Watch Topic
  • New Topic