Solved

open pdf in browser window

Posted on 2006-10-23
5
10,463 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to group array of objects ? 5 80
reflection example 3 133
Java Script nested call 3 91
HTTPSessionBindingListernter not configured in deployment descriptor 2 76
Had a business requirement to store the mobile number in an environmental variable. This is just a quick article on how this was done.
Recently I was talking with Tim Sharp, one of my colleagues from our Technical Account Manager team about MongoDB’s scalability. While doing some quick training with some of the Percona team, Tim brought something to my attention...
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Suggested Courses

752 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