Solved

open pdf in browser window

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

In this article, you will read about the trends across the human resources departments for the upcoming year. Some of them include improving employee experience, adopting new technologies, using HR software to its full extent, and integrating artifi…
A procedure for exporting installed hotfix details of remote computers using powershell
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now