How to Generate Dynamic Content Using JasperReports?

What is JasperReports?

JasperReport is a part of the LisoG open source java reporting tool which has capability in delivering content to a variety of targets such as Printer, Screen, Microsoft Excel, HTML, PDF, XML, RTF, Comma-separated values or ODT files.

It can read instructions from .jasper / XML files and can be used in web applications or Java-enabled applications such as Java EE, to generate effective content.

The main purpose of JasperReports is to generate page-oriented, ready to print documents in a flexible and simple manner.


JasperReports Architecture

Software Requirements

The primary software requirements are JasperReports server and iReport designer. JasperReport server will enable delivering critical information on a scheduled basis to the web, to the printer, or to other file formats. The important application features of JasperReports server are security, scheduling and storage. iReport or Jaspersoft Studio is a popular visual designer tool for JasperReports server that supports almost all the output formats and data sources.


Following are the free software download destinations for JasperReports server and iReport designer respectively.


Hardware Requirements

For proper running of JasperReports server, you need basic system requirements and JVM settings like memory reallocations, etc. Implementation of JasperReports server needs additional resources like memory or CPU depending on specific usage. For proper behavior of JasperReports server, it is suggested that your browser security settings were set to support the following:

  • Cookies
  • JavaScript
  • AJAX
  • Pop-ups (new windows/tabs)

Some concerns to consider before implementing JasperReports server:

  • Apache Tomcat (with JDK1.6) can be used as Java container
  • Use 64-bit systems instead of 32-bit to avoid JVM memory limits
  • Addition of CPU cores will increase concurrent report executions
  • Assign RAM between 1.5 to 2.5 GB per each physical core (Jaspersoft support recommends 4 GB RAM)
  • Follow the best practices of your RDBMS vendor


Steps to create JasperReports

  • Get the JSON Value from the file or the request


  • Create JSON Data Source and map with required parameter
  • Build a jasper template based on the JSON data with presentable styles

 Step 2

  • Compile the jasper template
  • Fill the jasper template with data source and parameters from map
  • Export the jasper template in different formats like PDF, Excel, HTML, etc.


Vmoksha’s expertise in JasperReports

Vmoksha has developed multiple reports with dynamic content using JasperReports. An example of JasperReports output, which is prepared with the intention of a one-page case study is as shown below:



Challenge and Solution

Let’s have a look at what challenge we have come across while working on JasperReport and how we solved the problem sensibly in time.


Challenge Solution
Several iterations within a JSON object which contain different child JSON’s made the report complex for interpretation We split the JSON data into multiple sub reports, which made the report more efficient and effective for rendering


Keep checking my blog for more updates on JasperReports.