Java Reference
In-Depth Information
The next two arguments for the JasperRunManager.runReportToPDFStream()
method are java.util.Map and JRDataSource . The former is used to pass
any parameters to the report, the latter to pass data in the form of a net.
sf.jasperreports.engine.JRDataSource . Since we are not passing any parameters
or data to this simple report, an empty HashMap and JREmptyDataSource suffice.
To make sure the browser displays the report properly, we must set the content type
to application/pdf . We can accomplish this by calling the javax.servlet.http.
HttpServletResponse.setContentType() method.
The resulting code for this example needs to be deployed to a servlet container.
An ANT script to automate this process can be found at this topic's website. The
following screenshot shows the report being displayed as a PDF on a browser:
Elements of a JRXML Report Template
In the previous example, we used the <detail> element of the JRXML report
template to generate a report displaying some static text. The <detail> element
is used to display the main section of the report. However, JRXML templates can
contain many other elements that allow us to display secondary data on the report,
Search WWH ::

Custom Search