• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
Bartenders:
  • Carey Brown
  • salvin francis
  • Claude Moore

How to generate PDF Jasperreports in browser without save it.  RSS feed

 
Cezar Apulchro
Ranch Hand
Posts: 103
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
How to show my jasperreports only in browser.

This servlet are working fine, but are asking to save, I don't want save it.

Thanks in advance.
 
Tim Moores
Saloon Keeper
Posts: 5391
143
Android Firefox Browser Mac OS X Safari Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's a client-side setting. Look through your browser settings - somewhere you can specify what should happen for a particular MIME type, whether it saves it, or tries to display it. That assumes your browser can display PDFs, obviously.
 
Tim Holloway
Saloon Keeper
Posts: 20635
122
Android Eclipse IDE Java Linux Redhat Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't generate the PDF "in the browser". You generate it on the server. The server then packs it into the response stream for the HTTP service request that caused the PDF to be generated.

When the client receives this response stream, it sees the "Content-Type" header which tells it that this stream contains a PDF and not HTML, an Excel spreadsheet, or something else.

The Content-Type is what is known as a MIME type (Multipart Internet Mail Extension), and the browser has a table of MIME types and actions to take, depending on which MIME type it receives. This table can usually be edited as part of the browser preferences, so that, for example, you can pick which one of possibly several different PDF viewer programs which open and display it or for it to simply display a File Save dialog and save the file without displaying it.

Also, you can use a Content-Disposition HTTP header to indicate that content that would normally be processed by a content application (PDF reader) should instead preferably be saved as a file, but there is no option for the reverse. For one thing, as I mentioned, if the client's normal behaviour was supposed to save the content, there wouldn't be a program defined to display it - you can only have one or the other.

The server cannot change this option, which is yet another protection against malicious servers. After all, if I could say that the action for content of type Application/X-pdf was "Format C:", I could really hurt a lot of website visitors (unless they run MacOS or Linux). Plus, I've probably got at least 3 different applications that can view PDFs, not counting a PDF editor or two on the machine I'm using now, so how would the service know which ones were installed or which one I preferred?

Aside from that, displaying a PDF in a browser window isn't even possible on many systems. A stand-alone viewer application must be launched. There was a patent filed controlling that sort of thing, and Microsoft got sued for half-a-billion dollars. And lost. Which is why Internet Explorer did not allow viewing PDFs - or even Excel spreadsheets - in a browser window ever since. Technologically it was possible. Pre-lawsuit IE versions and many Linux browsers could do it. But legally, they could not do it.
 
Cezar Apulchro
Ranch Hand
Posts: 103
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I did a test in IE and it worked fine, show my report only in browser but in Google Chrome he open window to save pdf file.
 
Tim Moores
Saloon Keeper
Posts: 5391
143
Android Firefox Browser Mac OS X Safari Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I said, that's a client-side issue. See here for Chrome: https://support.google.com/chrome/answer/6213030?hl=en
 
Cezar Apulchro
Ranch Hand
Posts: 103
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Very very good, problem is solved.

Thanks a lot and best regards.
 
To do a great right, do a little wrong - shakepeare. twisted little ad:
Create Edit Print & Convert PDF Using Free API with Java
https://coderanch.com/wiki/703735/Create-Convert-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!