Use eclipse to display the Crystal Report on JSP (1) simplest example

Source: Internet
Author: User
Tags tld server memory apache tomcat

 

The development ide I use is eclipse3.2, and the server is Tomcat 5.5.

Create a Crystal Reports Web project

Select Apache Tomcat v5.5 at target Runtime

In the next step, Crystal Reports Java reporting component, dynamic web module, and Java are selected by default. These three are required. You can also add struts, later settings will require you to add the struts class library. Add the example database and report to the end by default.

This is a Crystal Reports Web project (the above steps should be completed by people on earth)

There is a crystalreport1.rpt and crystalreport_viewer.jsp in it.

Right-click crystalreport_viewer.jsp-> running mode-> run on server, and click Finish.

You should be able to see an empty crystal report (Why? Of course, crystalreport1.rpt itself is empty)

In the sample reports folder, there are four examples. RPT report file, right-click any of them, select Crystal Reports-> Create viewer JSP, And A *-Viewer will be created. JSP file. Run this file and you will see a crystal report.

I think this should be no problem for most people. The rest is to analyze all the things in this project.

Certificate -------------------------------------------------------------------------------------------------------------------------------------------------------

What is required in any project? For this reason, I specially set up a new Tomcat project. It is best to create a simple JSP page to test whether your Tomcat project can run normally.

Through my own experiment, if you run the Crystal Report in JSP of other projects, you need the class file and configuration.

1. Add a user Library such as crystalreports libraries and add the following *. Jar

Commons-collections-3.1.jar, commons-configuration-1.2.jar,
Commons-lang-2.1.jar,
Commons-logging.jar,
Concurrent. jar,
Crystalcharting. Jar
Crystalcommon. Jar
Crystalcontentmodels. Jar
Crystaldatabaseconnectors. Jar
Crystalexporters. Jar
Crystalexportingbase. Jar
Crystalformulas. Jar
Crystalqueryengine. Jar
Crystalreportengine. Jar
Crystalreportingcommon. Jar
Derby. Jar
Icu4j. Jar
Jrcadapter. Jar
Jrcerom. Jar
Keycodedecoder. Jar
Log4j. Jar
Metafilerenderer. Jar
Msbase. Jar
MSSQLServer. Jar
Msutil. Jar
Rasapp. Jar
Rascore. Jar
Reportprinter. Jar
Rpoifs. Jar
Serialization. Jar
Uriutil. Jar
Webreporting. Jar
Webreporting-jsf.jar
Xercesimpl. Jar
Xml-apis.jar
Xtreme. Jar

(A total of 36 jar files, some of which are already available in other libraries, just add this user-defined Library to the Project)

 

2. Place the crystalreportviewers folder in the previous example in the same directory as the WEB-INF folder. This is the basic framework of the Crystal Report, which is equivalent to the source code of the Crystal Report control in. net.

3. Put the crystal-tags-reportviewer.tld under the WEB-INF, the main label

 

4. Add web. XML in the middle of <web-app> to read crystalreportviewers

<Context-param>
<Param-Name> crystal_image_uri </param-Name>
<Param-value> crystalreportviewers </param-value>
</Context-param>
<Context-param>
<Param-Name> crystal_image_use_relative </param-Name>
<Param-value> webapp </param-value>
</Context-param>

 

5. Put crconfig. XML in the SRC folder. The configuration file of the crystal report. If you have registered, the registration code will also be in this file.

Crconfig. xml

<? XML version = "1.0" encoding = "UTF-8"?>
<Crystalreportengine-configuration>
<Reportlocation>.../</reportlocation>
<Timeout> 0 </timeout>
<Externalfunctionlibraryclassnames>
<Classname/>
</Externalfunctionlibraryclassnames>
</Crystalreportengine-configuration>
Configure timeout Interval

ExploitationCRConfig.xmlFile, you can configure the timeout interval (in minutes) to determine when to discard the inactive report source ). This is necessary because the inactive report source still consumes system resources (such as disk space used by database connections, server memory, and temporary files ). You canCRConfig.xmlFile SettingstimeoutTo specify the timeout interval. By default, the timeout interval is 10 minutes. By setting this value to 0, you can set Java reporting component to no timeout.

The timeout interval applies only to non-active reports. A report that is being processed does not time out because it exceeds this value. Each time a report source request is successfully completed, the timeout timer is reset. If a report source is not used during the timeout interval, the report source is discarded and its resources are provided to other processes.

6. insert this code on the JSP page

<% @ Taglib uri = "/crystal-tags-reportviewer.tld" prefix = "crviewer" %>
<Crviewer: viewer reportsourcetype = "reportingcomponent" viewername = "rcname-Viewer" reportsourcevar = "rcname" isownpage = "true">
<Crviewer: Report reportname = "rcname. rpt"/>
</Crviewer: viewer>

Like using the crystal report control in. net, not only the viewer, but also the partviewer.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.