JasperReports Ultimate Guide - Sample Reference - Schema Reference - Configuration Reference - API (Javadoc)

JasperReports - Webapp Sample (version 4.6.0)


Shows how reporting functionality could be added to a Web application.

Download All Sample Source Files
Browse Sample Source Files on SVN


Main Features in This Sample

Deploying Reports in Web Applications


top

Deploying Reports in Web ApplicationsDocumented by Luke Shannon


Description / Goal
How to add reporting functionality to a Web application.

Since
0.4.4


Once a report is created the next challenge is to make this available to your report users. This sample
reviews embedding a JasperReports template into a Java Application.
The technology used are simple Servlets and JSP.
This sample also demonstrates:
  • Configuring and using several of the JasperReports exporters
  • Viewing a report in Flash
  • Viewing a report in an Applet
  • Creating and using an XML Datasource


Setting Up The Sample Prerequisites
Ant is required. By running 'ant --version' you will be able to check if ant is set up on your system (at least version 1.5 is required):
    
    C:\>ant -version Apache Ant version 1.8.0 compiled on February 1 2010
	
	
You can obtain ant from http://ant.apache.org/, instructions for installation can be found there as well.
Also before generating this sample you will need to run the jar ant command in the build file at the
in the root of the project. This will generate JasperReports jar files in the dist directory of the root
level. These jars are using in the web app sample, the sample will not function without them.
Generating the Application
Open up a separate command prompt/terminal window and browse to the root directory of the sample.
By running 'ant -p' you will be presented with a list of options available. Of interest in this list is all the exporters available for testing.
By running the command 'war' the following actions will be performed:
  • All the dependancies will be copied to the WEB-INF\lib directory
  • All required Java classes will be compiled
  • The dependancies, class files and any other files will be packaged into a war file
The war file will be generated in the root level of the project. This file can be deployed in a Java application server such as Tomcat (simply place
the file in the webapps folder and restart the server).
You now have a working version of the app you can review.

Folder Structure and Resources
Compiling the JRXML
Filling the Report
Exporting the Report
Applet Viewer
Flash Viewer
Further Resources:
JasperReports Ultimate Guide (available from the JasperSoft eShop)
iReport Ultimate Guide (available from the JasperSoft eShop)



© 2001- Jaspersoft Corporation www.jaspersoft.com