Before you can use the export control or viewer in your JSP pages, you must obtain a report source.
A report source is an object that represents a single instance of a report that is used by both the export control and the viewer. The Java Reporting Component, Page Server and RAS can be used to obtain report sources.
To create a report source using the Java Reporting Component, you must have the location of the report you want to view or export. The report location is specified by using a relative or absolute path. Also, for the Java Reporting Component to correctly retrieve data for a report, the report's data sources must be correctly specified through JNDI or the report must be designed against a JDBC data source.
There are two ways to obtain a report source with the Java Reporting Component. The first (and recommended) method is to use the ReportClientDocument class to obtain a report source. The second method is to use the IReportSourceFactory2 class.
import com.crystaldecisions.reports.sdk.ReportClientDocument;
ReportClientDocument reportClientDoc = new ReportClientDocument();
String report = "/reports/sample.rpt";
reportClientDoc.open(report, 0);
Object reportSource = reportClientDoc.getReportSource();
Note: The report location in the above code differs depending on if you use relative or absolute paths. When using relative paths, the above report would resolve to <web_app_dir>/WEB
session.setAttribute("reportSource", reportSource);
Note: The report used in this example is not included with the tutorials.
<%@ page import="com.crystaldecisions.reports.reportengineinterface.JPEReportSourceFactory" %>
<%@ page import="com.crystaldecisions.sdk.occa.report.reportsource.IReportSourceFactory2" %>
IReportSourceFactory2 rptSrcFactory = new JPEReportSourceFactory();
String report = "/reports/sample.rpt";
Object reportSource = rptSrcFactory.createReportSource(report, request.getLocale());
Note: The report location in the above code differs depending on if you use relative or absolute paths. When using relative paths, the above report would resolve to <web_app_dir>/WEB
. When using absolute paths, the above report resolves to <web_app_dir>/WEB
first, and then /reports/sample.rpt
.
session.setAttribute("reportSource", reportSource);
Note: The report used in this example is not included with the tutorials.
Business Objects http://www.businessobjects.com/ Support services http://www.businessobjects.com/services/support/ |