Viewing a report using a managed RAS server

This is sample shows you how to use the Viewer Tag Library to display a report using a managed Report Application Server report source.

To view a report using a managed RAS server
  1. Log on to Crystal Enterprise and get an InfoStore object.

    In this case, the default administrator account is used to log on to a Crystal Enterprise installation running on the same machine as the application server.

    <%

        IEnterpriseSession es = CrystalEnterprise.getSessionMgr().logon("administrator", "", "localhost", "secEnterprise");

        IInfoStore infoStore = (IInfoStore) es.getService("","InfoStore");

  2. Query for the report you wish to view.

        IInfoObjects infoObjects = infoStore.query("SELECT * FROM CI_INFOOBJECTS WHERE SI_NAME='World Sales Report'");

        IInfoObject report = (IInfoObject) infoObjects.get(0);

  3. Create a RAS report source for the report you retrieved.

        IReportSourceFactory2 rsFactory = (IReportSourceFactory2) es.getService("RASReportFactory");

        IReportSource rptSrc = rsFactory.createReportSource(report, request.getLocale());

  4. Cache the ReportSource object in a session variable.

    This allows it to be retrieved by the viewer.

        session.setAttribute("ReportSource", rptSrc);

    %>

  5. Create a viewer tag, specifying the viewer name, report source type, and report source variable.

    In this case, the reportApplicationServer report source is being used and the report source variable refers to the session variable where you stored the ReportSource object.

    <html>

    <body>

    <crviewer:viewer viewerName="CrystalViewer" reportSourceType="pageServer" reportSourceVar="ReportSource" />

    </body>

    </html>

    Note:    In this case, a report tag is not needed because the report source has already been cached in a session variable and does not to be retrieved by the viewer.



Crystal Decisions
http://www.crystaldecisions.com/
Support services
http://support.crystaldecisions.com/