This is sample shows you how to use the Viewer Tag Library to display a report using a Page Server report source.
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");
IInfoObjects infoObjects = infoStore.query("SELECT * FROM CI_INFOOBJECTS WHERE SI_NAME='World Sales Report'");
IInfoObject report = (IInfoObject) infoObjects.get(0);
IReportSourceFactory2 rsFactory = (IReportSourceFactory2) es.getService("PSReportFactory");
IReportSource rptSrc = rsFactory.createReportSource(report, request.getLocale());
This allows it to be retrieved by the viewer.
session.setAttribute("ReportSource", rptSrc);
In this case, the pageServer report source is being used and the report source variable refers to the session variable where you stored the ReportSource object.
<crviewer:viewer viewerName="CrystalViewer" reportSourceType="pageServer" reportSourceVar="ReportSource" />
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/ |