views:

3305

answers:

3

We want to generate Reports either embedded as html pages in a web app or downloadable as a pdf. Hence I came across Jasper Reports because it thought it would fullfill these requirements.

Currently we assume our report will have about 50-100 pages, consisting of nearly only histograms and some tables. The data is retrieved by some expensive queries from our DB.

After evaluating it the whole day i have several doubts regarding web app aspects.

1) Pagination: Of course i don't want to display all pages in a single web page. we need something like pagination. but Jasper Reports seems not to support this approach. The wepp demo, which comes with Jasper Reports, sketches the way to go: I have to create a JasperPrint, which is already the full report, allocating unrequired memory and which has performed the expensive queries. Then I could display a single page. But doing this again and again for each page does not appear as a proper solution to me.

2) As mentioned above, our report will mostly consist of diagrams. Images are generated during Exporting the JasperPrint to its output format. If I understand everything correct, the ImageServlet, which comes with Jasper, is capable but retrieve these images bei i) Reading the generated images from the file system ii) the exporter has stored them in the session (therefore in memory).

Since I think we will have a lot of images ii) is not an option, if we want to keep the memory footprint of the webapp low. But on the other hand flooding the file system with files is also not the best idea i could imagine. Does it delete the files somewhen?

Did I got something wrong? Is my understanding Correct?

Thanks, Lars

+1  A: 

Pagination

It's kind of your service design how your pageing ist implemented! PDF is an standalone output format for printing issues. It can't read more data from the server (without Web-Services and Reader Extensions). So you can define, that JasperReports should only a subset of your data for paging.

If you define datasets in JasperReports, you can reuse them without allocating unrequired memory.

Images

If you want images in your reports and keep your memory footprint low, write a balancing algorithm which generates the images when the server load is under a specified value (may be a dynamic value from the avg of the last day load).

Do you need real time creation of the images? If the images were created by a servlet, they'll be load to Memory. A Java App. can pass the images to the ReportGenerator.

images can be loaded from memory, from disk, or from a URL see; Jasper Reports Book P:170

The images should never be saved in the HTTP_SESSION! This is a total antipattern which causes memory bloating.

Martin K.
A: 

No. You will have all sorts of problems.

I think that you just can generate your reports in XHTML/CSS, and if you need PDF rendering, just use Flying Saucer XHTML renderer.

Alexander Temerev
A: 

Hi All,

I am using jasper report with my application and generating the reports in pdf formats, which are coming up fine. We want the user to be able to view those reports in html also with in the application, but generating HTML from jasper contains inline CSS for its individual element which we do not want. (We want to apply our own CSS so that look and feel of application remains same.). If any body has any ideas how it can be done, please help.

Also we do not want large number of records in a single page in html, so any ideas on how we can implement pagination in such a scenario.

Sachin Anand