How to create a report source

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.

To create a report source object using ReportClientDocument
  1. Ensure that you have imported the ReportClientDocument class.
  2. import com.crystaldecisions.reports.sdk.ReportClientDocument;

  3. Create an instance of the ReportClientDocument class.
  4. ReportClientDocument reportClientDoc = new ReportClientDocument();

  5. Call the ReportClientDocument object's open method, passing it the path to the desired report and the current locale settings.
  6. 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-INF/lib/reports/sample.rpt. When using absolute paths, the above report resolves to <web_app_dir>/WEB-INF/classes/reports/sample.rpt first, and then /reports/sample.rpt.

  7. Once you have obtained a report source, you must cache the report source in the session variable when using the Java Reporting Component.
  8. session.setAttribute("reportSource", reportSource);

Note:    The report used in this example is not included with the tutorials.

To create a report source using IReportSourceFactory2
  1. Ensure that you have imported the JPEReportSourceFactory class and the IReportSourceFactory2 interfaces.
  2. <%@ page import="com.crystaldecisions.reports.reportengineinterface.JPEReportSourceFactory" %>

    <%@ page import="com.crystaldecisions.sdk.occa.report.reportsource.IReportSourceFactory2" %>

  3. Create a new JPEReportSourceFactory object.
  4.     IReportSourceFactory2 rptSrcFactory = new JPEReportSourceFactory();

  5. Call the IReportSourceFactory2 object's createReportSource method, passing it the path to the desired report and the current locale settings.
  6. 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-INF/lib/reports/sample.rpt. When using absolute paths, the above report resolves to <web_app_dir>/WEB-INF/classes/reports/sample.rpt first, and then /reports/sample.rpt.

  7. Once you have obtained a report source, you must cache the report source in the session variable when using the Java Reporting Component.
  8. 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/