Integrating JasperReports with Spring

Spring (http://www.springframework.org) is a very popular framework that helps simplify the development of Java EE applications. The Spring Framework integrates nicely with JasperReports. In this section, we will develop a simple web application using Spring Web MVC, which is Spring's native web application framework.

The web.xml for our simple application is as follows:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app PUBLIC"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
  <servlet>
    <servlet-name>jasperSpring</servlet-name>
    <servlet-class>
      org.springframework.web.servlet.DispatcherServlet
    </servlet-class>
 <load-on-startup>1</load-on-startup> ...

Get JasperReports 3.5 for Java Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.