I. Completely silly
- Add a reference pointing to the viewer tag library descriptor file to the top of the JSP page. At the same time, make sure that the corresponding jar files and additional support files exist.
<% @ Taglib uri = "/Crystal -T AGS -R Eportviewer. TLD "prefix =" crviewer "%>Note:You can specify any name for the prefix attribute. Prefix: Determine the tag prefix used to access the tag of the tag library.
- Create a start viewer tag. In this tag, specify the viewer name and report source type.
<Crviewer: viewer viewername = "crystalviewer" reportsourcetype = "reportingcomponent">
- Create the required report tag.
This tag specifies the report to be displayed and the session variable to be used to cache the report source.
<Crviewer: Report reportname = "/reports/sample. rpt"/>
- End the viewer tag. The JSP page can now be viewed
sample.rpt
.
</Crviewer: viewer>
Ii. Custom report source
1. Add a reference pointing to the viewer tag library descriptor file to the top of the JSP page. At the same time, make sure that the corresponding jar files and additional support files exist.
<% @ Import = "com. crystaldecisions. Reports. SDK. reportclientdocument">
<% @ Taglib uri = "/Crystal -T AGS -R Eportviewer. TLD "prefix =" crviewer "%>
Note:You can specify any name for the prefix attribute. Prefix: Determine the tag prefix used to access the tag of the tag library.
2. Create a report source, set the properties of the report source, and cache the report source in the session variable (required)
<%
Final string reportname = "Rpt/sample. rpt ";
Reportclientdocument crdoc = new reportclientdocument ();
Crdoc. Open (reportname, 0 );
Crdoc. getdatabasecontroller (). Logon ("sa ","");
Session. setattribute ("reportsource", crdoc. getreportsource ());
%>
Note: If the default value of the reportsourcevar attribute marked by viewer is crystalreportsource, you do not need to set reportsourcevar if you use this parameter as the session variable name.
3. Create a start viewer tag. In this tag, specify the viewer name and report source type.
<Crviewer: viewer viewername = "crystalviewer" reportsourcetype = "pageserver" reportsourcevar = "reportsource">
4. End the viewer tag. On the JSP page, you can view the report named sample.
</Crviewer: viewer>