Java Reference
In-Depth Information
The last step needed to make this technique work properly is to set up the web.xml
file to use JSF.
<?xml version="1.0" encoding="ISO-8859-1"?>
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
<servlet-name>Faces Servlet</servlet-name>
<servlet-name>Faces Servlet</servlet-name>
This tells the web container to use the javax.faces.webapp.FacesServlet servlet
to process any requests for file names ending in .jsf . Of course, in order for this to
work, a JAR file containing an implementation of the JavaServer Faces specification
must be in the CLASSPATH. For this example, we used the Apache licensed
MyFaces implementation.
Integrating JasperReports with Struts
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.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;
Search WWH ::

Custom Search