JSP tag library for easy inclusion of reports in web applications


JasperTags can read report definitions that are stored both in the context of the Webapplication (i.e are deployed with the WAR) or in an folder that is "outside" of your application.

NB! JasperTags has been developed and tested using JBoss AS 4.x, but should work on other application servers as well

The easiest way to start using JasperTags in your application is to:

  1. copy jaspertags-*.jar to the WEB-INF/lib folder of your Web application
  2. make sure you have all the required libraries in your WEB-INF/lib folder
  3. create the folder WEB-INF/reports and copy some JasperReport definitions (.jrxml-files) to that folder
  4. add a "resource-ref" element to your applications web.xml file pointing to a JNDI bound java.sql.Datasource (to set up JNDI bound datasources, consult the documentation of your application server). An alternative method is to use the sql:setdatasource tag from the Java Standard Template Library (JSTL) to define a valid datasource.
  5. add code such as this to your JSP page (subsitute the value for "reportfile" with the name of your report definition file minus the file extension (.jrxml), ex.: myReport.jrxml -> myReport) <%@ taglib prefix="report" uri="http://jaspertags.sf.net/report" %>
    <report:define var="myReportVar" reportfile="myReport"/>
    <report:fill report="${myReportVar}" datasource="jdbc/datasource" />
    <report:show report="${myReportVar}" />
  6. Et voilá!

Note: if your report takes parameters, you can add them to the URL of the JSP. JasperTags will automatically loop through GET/POST parameters and match them against the parameters defined in your report definition. If the value of the request parameter does not match the datatype defined in your report definition file, it will simply ignore that parameter.

This makes it easy to integrate as you can build a form using your favourite framework and update the report output based on the values of the parameters defined in that form

JasperReports is a trademark for JasperSoft Corporation.

Java is a trademark for Sun Microsystems, Inc.