Integrating JasperReports with Struts

The Struts framework is the most popular Java web application framework. Typically, Struts applications consist of JSP's, action classes that serve as the controller component of MVC, form beans that map HTML form elements, and an XML configuration file. For more information on the Struts framework take a look at "Learning Jakarta Struts 1.2", Stephan Wiesner, Packt Publishing. JasperReports and Struts integration consists of writing a controller that will generate a report when executed.

The following action class demonstrates this technique:

package net.ensode.jasperbook.struts; import java.io.InputStream; import java.sql.Connection; import java.sql.DriverManager; import java.util.HashMap; import javax.servlet.ServletOutputStream; ...

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.