• 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

jsf: open pdf in browser

 
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have post a similar post in "other open source projects forum", but not getting any reponse, thus trying here to get some response.

i having in opening the pdf, i want to have dialog bos to pop up asking user to save or open the file:

full details in :
https://coderanch.com/t/446738/Other-Open-Source-Projects/jsf-jasper-report-pdf-format

with the piece of code:
IE: nothing happens when i click on the command button, the method is call without any error
FF: new window open up, with binary data

I tried also using:
response.setHeader("Content-disposition", "inline; filename=\""+filename +".pdf\"");
both IE and FF nothing happens when i click on the command button, the method is call without any error.


anyone?

Thanks.


 
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So, I can anticipate a number of problems with this design flaw, not the least of which is pop-up blockers. I know when Chrome downloads something, it just puts an icon in the lower left-hand corner, which can easily be missed.

Why not have a link on the page that just allows the user to right-click on the link and select Save-As, as they would in any browser. Or, just allow the PDF to open, and have the user use the native Save option provided by Adobe/Foxit.

I know it's not solving the problem. But simply doing a redesign might actually eliminate the problem altogether. Plus, nobody likes pop-ups.

-Cameron McKenzie
 
lynn fann
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well of cause, i know popup is not a good idea. but i dont really mean as "pop up window". I set the
response.setHeader("Content-disposition", "attachment; filename=\""+filename +".pdf\""); this will instruct the browser to attached the file to the reponse, so that user can download the file.


Why not have a link on the page that just allows the user to right-click on the link and select Save-As, as they would in any browser


I do not want to store the file on my server. I just want to generate the file on-the-fly for the user



Or, just allow the PDF to open, and have the user use the native Save option provided by Adobe/Foxit.



I have thought about this. but my problem is now i cannot even get the PDF to open.. using
response.setHeader("Content-disposition", "inline; filename=\""+filename +".pdf\"");

 
Cameron Wallace McKenzie
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good points.

I might try a quick test and see if you can get it to work in both browsers with an Excel document, or some other type of application or data file. It might be worth seeing if it is a pdf specific issue, or an issue that's just coming up with that particular MIME type mapping?

Just an idea.

-Cameron McKenzie
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I hope you haven't started parallel discussions here. There's a reason why we really prefer to have people only run a topic in one place.

Internet Explorer is prohibited from opening PDF's embedded within a browser window. The "technology" required to do so is patented by a small company who sued Microsoft for a half a billion dollars and won. So Microsoft was obliged to remove that feature. Regardless of what you set your headers to, IE users will always get a separate stand-alone application launch for PDF's, Excel spreadsheets and other documents that were formerly embeddable. Just to make it more confusing, it's the up-to-date Windows systems where you'll see this. There were still some older ones that could embed last time I looked. But that was a while back.

Embedding is supposed to be legal in FireFox and on non-Windows machines, by permission of the patent holder (whose name I have forgotten at the moment). However, they, too sometimes are set up not to embed.

Finally, I believe that the embed/non-embed option was a user-settable option in at least some systems.

If you get nothing back at all, you've got a webapp bug. But embedability is system-specific.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I try to focus to your question first. I 've done a project which is similar to your suitation. But i used to following fragment code instead of yours,




After you clicked the link of the servlet which contained the above codes, there was a window prompted out and asked you whether you save or open the file and did not leave a file in a server. Hope it helps
 
reply
    Bookmark Topic Watch Topic
  • New Topic