Solved

open pdf in browser window

Posted on 2006-10-23
5
10,460 Views
Last Modified: 2012-05-05
I have a jsp page that should display the pdf report. PDF is opened in acrobat reader and is shown outside of browser window. In the pdf preferences, I checked "Display pdf in browser". Still I could not open pdf in browser window. The browser window is empty after the pdf is opened. PDf is opened in acrobat reader.

Here is the code snippet
Javascript code
------------------
function submitForm()
{
  form = document.abcForm;
  form.target=_self;
  form.submit();
}

Servlet code
--------------
response.setHeader("Content-Type", "application/octet-stream");
response.setHeader("target", "abc.pdf");
response.setHeader("title", "ABC Report");
response.setHeader("Content-Disposition", "inline; filename=abc.pdf;");

Where am I going wrong.
0
Comment
Question by:lakki
  • 3
  • 2
5 Comments
 
LVL 10

Accepted Solution

by:
jaggernat earned 125 total points
ID: 17789981
try

httpServletResponse.setContentType("application/pdf");

instead of


response.setHeader("Content-Type", "application/octet-stream");

0
 

Author Comment

by:lakki
ID: 17790291
That fixes the problem on hand. I am wondering why would anyone declare octet-stream instead of pdf.
Its a legacy application. Not sure the reasons behind writing it as octect-stream. Any idea?

I know Octet-stream is generic (dll, exe etc..) and so browser may not recognise it as pdf. But acrobat reader does.

0
 
LVL 10

Expert Comment

by:jaggernat
ID: 17790324
application/octet-stream  is more generic. Since  you know for sure you are opening a pdf file, its always better to give application/pdf.

http://kb.iu.edu/data/agtj.html
0
 

Author Comment

by:lakki
ID: 17790438
Thanks for your help
0
 
LVL 10

Expert Comment

by:jaggernat
ID: 17790979
u r welcome
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
servlet init param and contect param 3 67
console vs log file 16 83
lessBy10  challenge 15 95
timeToIdleSeconds vs timeToLiveSeconds in hibernate second level cache 3 139
This article describes how to reset your Windows 10 password when you've forgotten it.
The advancement in technology has been a great source of betterment and empowerment for the human race, Nevertheless, this is not to say that technology doesn’t have any problems. We are bombarded with constant distractions, whether as an overload o…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question