The Struts framework is the most popular Java web application framework. Typically, Struts applications consist of JSP, 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 (ISBN: 1-904811-54-X) by Packt Publishing. JasperReports 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; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import net.sf.jasperreports.engine.JasperRunManager; import org.apache.struts.action.Action; import org.apache.struts.action.ActionForm...