As we can see, integrating JasperReports and Hibernate is trivial. Since Hibernate
is a very popular Object-Relational Mapping tool, this integration was a welcome
addition to JasperReports 1.2.
Integrating JasperReports with Spring
Spring ( http://www.springframework.org ) is a very popular framework that helps
simplify 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"
-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
As can be seen in this web.xml code, there is only one servlet in our application.
This servlet, called the DispatcherServlet , is provided by the springframework .
Please note that we named our servlet jasperSpring to make it clear that this
instance of DispatcherServlet will be used to generate reports. However,
DispatcherServlet is not specific to JasperReports functionality.
Each application developed with the springframework must contain an application
context, which is usually an XML file containing additional configuration. For Spring
Web MVC applications, the application context is named after the servlet, following
the servletname-servlet.xml pattern. For our application, the application context
file is named as jasperSpring-servlet.xml .