Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

open pdf in browser window

Posted on 2006-10-23
5
Medium Priority
?
10,476 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 500 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Check out what's been happening in the Experts Exchange community.
By default Outlook 2016 displays only one time zone in the Calendar. The following article explains how to display two time zones in one calendar view.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

705 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