Java Reference
In-Depth Information
<reportElement x="20" y="60" height="20" width="500"/>
<textFieldExpression>
<![CDATA["Total Rotorcraft Aircraft Models: " +
$F{rotorcraft_cnt}]]>
</textFieldExpression>
</textField>
<textField>
<reportElement x="20" y="80" height="20" width="500"/>
<textFieldExpression>
<![CDATA["Total Aircraft Models Reported: " +
($F{fixed_wing_single_engine_cnt}.intValue() +
$F{fixed_wing_multiple_engine_cnt}.intValue() +
$F{rotorcraft_cnt}.intValue())]]>
</textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
This JRXML generates a report on the total number of fixed-wing single-engine,
fixed-wing multiple-engine, and rotorcraft aircraft in the FlightStats database. It then
calculates the total number of fixed-wing aircrafts in the database by adding the first
two fields. Lastly, it calculates the total number of aircraft reported by adding all
three fields.
The following servlet generates a PDF report from the Jasper file generated by the
above JRXML template and directs it to the browser:
package net.ensode.jasperbook;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.util.HashMap;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.sf.jasperreports.engine.JasperRunManager;
 
Search WWH ::




Custom Search