You can do several things to improve the performance of web applications that make use of the viewer to display reports. These techniques range from optimization of the reports themselves to coding practices that improve the efficiency of your applications.
Click the appropriate link to jump to that section:
You can view potential performance bottlenecks in your report design by going to the Report menu in the Crystal Reports Designer and clicking Performance Information. The Crystal Reports Online Help contains a chapter with a detailed overview on how to create efficient reports titled "Designing Optimized Web Reports." Following the recommendations listed there helps you improve your report viewing efficiency considerably.
Beginning with version 9, the viewer can work effectively
without being stored in a session variable on the web application server,
providing stateless viewing. Stateless viewing only works, however, for reports
that are read
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";
reportSource
= new JPEReportSource(report);
session.putValue("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.
If your JSP page contains only the viewer and nothing else, several things can be done ways to simplify the report viewing implementation.
The viewer is capable of generating complete HTML pages and can set the appropriate page properties depending on the viewing context. Setting the setOwnPage property to true provides several benefits, by allowing the viewer to completely handle the surrounding HTML content. Allowing the viewer to handle the surrounding HTML content reduces the amount of code you need to add to your JSP page and allows the viewer to automatically determine certain settings:
For example, it writes out the <html>
start tag for web browsers and <wml>
start tag for mobile
devices.
If setOwnPage is false, the surrounding HTML tags and
content
When setOwnPage is set to true, you must use the processHttpRequest method to display the report instead of getHtmlContent. The processHttpRequest method must be used because using getHtmlContent has the same effect as setting setOwnPage to false, negating any of the benefits gained from setting setOwnPage to true.
If your JSP page does not contain any controls that require
post back, you should set the setOwnForm method to true. Doing so, allows the
viewer to handle the view state information automatically. The view state is
used to perform client
The following example shows how to set the view state information manually:
viewer.setViewState((String)
session.getValue("viewState"));
viewer.processHttpRequest(request,
response, getServletContext(), pageContext.getOut());
session.putValue("viewState",
viewer.getViewState());
To send characters from a JSP file to a web browser, you
must use the correct encoding. Always specify the correct content
If your JSP page returns content to a standard HTML browser, ensure that the correct character set is defined:
<%@ page
contentType="text/html; charset=utf
The contentType and charset directives let the browser know
how the returned HTML page is encoded. UTF
Crystal Decisions http://www.crystaldecisions.com/ Support services http://support.crystaldecisions.com/ |