• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

pdf in browser

 
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
.
.
.

RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/MyServletPDF?username=TEST");
response.setContentType("application/pdf");
dispatcher.include(request,response);
%>

While debugging everything is going through... even it passes through the last line. But the pdf is not launching... showing only a blank screen in its status bar as "Connecting"... Earlier it was launching.. but suddenly this issue is raising up. Is there any IE settings need to be checked? Please help me. I'm totally struck up.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

%>


If this means that you're doing this in a JSP - don't, you will likely not succeed. Binary content needs to be handled in a servlet.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please read this article to find out why.
 
Neeba Rebbaca
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All pdf formation it in servlet .. here in jsp i'm only displaying in the browser. It was working till yesterday. Suddenly facing this issue. Not did any changes in code though.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

All pdf formation it in servlet .. here in jsp i'm only displaying in the browser.


Use a servlet to stream it to the browser instead.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Read the article -- it will tell you how JSP adds extra characters that can "pollute" a binary stream.
 
Neeba Rebbaca
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:

All pdf formation it in servlet .. here in jsp i'm only displaying in the browser.


Use a servlet to stream it to the browser instead.



I tired stream from servlet to the browser. still the same problem exists. Is there any browser setting issue will be there?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Post the server-side code you're using for streaming from a servlet. What the browser will do with the PDF is up to the browser - it might display it, it might save it, or it might ask what to do with it.
 
Neeba Rebbaca
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't think there is problem in the code, as it is working in other client machines. Its not working only in a particular m/c.
 
Rancher
Posts: 989
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Neeba Rebbaca wrote:I don't think there is problem in the code, as it is working in other client machines. Its not working only in a particular m/c.



That's because, as has been said, you have no control what happens to files if you stream them to a client from a servlet. The client machine might not have a PDF viewer application at all or the browser might have been setup so as not to launch other applications. You might even observe different behavior on different browsers on the same computer. The best you can do from the server side is set the right headers. What the client will do with those headers is anyone's guess.
 
Neeba Rebbaca
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

he client machine might not have a PDF viewer application at all or the browser might have been setup so as not to launch other applications.



Installed adobe pdf and other applications also launching.

The best you can do from the server side is set the right headers



What is the server side headers to be set?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Read up on the Content-Disposition HTTP header.
 
Neeba Rebbaca
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I launch the pdf from servlet inside the server, in browser it is showing as "Internet Explorer cannot display the webpage". The same code is working in other places.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think this may be be due to IE not using plugins to display embedded content; there was a lawsuit some years ago that prevents Microsoft from doing this. Or it could just be IE not behaving correctly; it has a long tradition of that :-)
 
reply
    Bookmark Topic Watch Topic
  • New Topic