Solved

open pdf in browser window

Posted on 2006-10-23
5
10,458 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

If you thought ransomware was bad, think again! Doxware has the potential to be even more damaging.
Data breaches are on the rise, and companies are preparing by boosting their cybersecurity budgets. According to the Cybersecurity Market Report (http://www.cybersecurityventures.com/cybersecurity-market-report), worldwide spending on cybersecurity …

831 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