Caching a report source in the session variable
allows it to be used multiple times efficiently. When a report source is not
cached, the process of creating a new report source multiple times becomes
fairly expensive. Furthermore, caching a report source allows reports with or
without saved data to be refreshed.
The following example shows how to cache a report
source in the session variable:
String report = "/reports/sample.rpt";
ReportClientDocument reportClientDoc = new ReportClientDocument();
reportClientDoc.open(report, 0);
Object reportSource = reportClientDoc.getReportSource();
session.setAttribute("reportSource", reportSource);
Note: If you are using a cached report
source, the dispose methods for the viewer or report source should not be
called until the report source is no longer being used.
It is highly recommended that you cache report
sources in order to ensure data consistency when viewing reports. Using an
uncached report source causes a new report source to be created when any action
is performed in the viewer or export control. As a result, using uncached
report sources causes the viewer to display some pages with saved data and
other pages with live data.