Integrating JasperReports with JSF
JavaServer Faces (JSF) is the standard technology for developing user interfaces for Java server applications. In theory, JSF is view technology agnostic (that is, it can be used to develop user interfaces for a variety of technologies). However, in practice, JSF is almost always used to develop web applications.
JSF applications typically consist of JSP and backing beans, with the latter serving as controllers for the former. JSF and JasperReports integration can be accomplished by creating a backing bean that will generate a report. The following example illustrates this technique:
package net.ensode.jsf; import java.io.IOException; import java.io.InputStream; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.util.HashMap; import javax.faces.context.FacesContext; import javax.faces.event.ActionEvent; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; import net.sf...