Crystal Reports Local Web display

Source: Internet
Author: User

1. Install Crystal Reports XI.
2. Copy the jar package from the following two directories to your developed web program.
From directory 1: <installation drive letter>: \ Program Files \ common files \ crystal decisions \ 3.0 \ Java \ Lib
Directory 2: <installation drive letter >:\ Program Files \ common files \ crystal decisions \ 3.0 \ Java \ Lib \ external
Go to the webroot/lib directory you developed
3. Copy crystalreportviewers11 to the webroot directory you developed under <installation drive letter>: \ Program Files \ common files \ crystal decisions \ 3.0 \, And the WEB-INF directory is hierarchical.
4. Open Web. xml under the web_inf directory of webroot and add
<Context-param>
<Param-Name> crystal_image_uri </param-Name>
<Param-value> crystalreportviewers10 </param-value>
</Context-param>
It should be noted that, if it is crystal report 10, the corresponding viewers is crystalreportviewers10. If it is Crystal Report XI, the corresponding viewers is crystalreportviewers11. If it is Crystal Report XI R2, the corresponding viewers is crystalreportviewers115.
5.: <installation drive letter >:\ Program Files \ common files \ crystal decisions \ 2.5 \ Java contains a configuration file crconfig. XML, if you are in the development environment now, you can copy crconfig to the SRC root directory so that it will be directly placed in the WEB-INF/classes directory during deployment. To deploy the environment, directly put it in the web_inf/classes directory.
6. Open the crconfig. xml file and change the "reportlocation" element from "..." to "...". This is the root directory of the report, which is relative to the parameter configuration file. If it is "..", then the upper-level directory of the classes directory is under the WEB-INF directory. For "../..", the upper-level directory in the WEB-INF directory is under the webroot directory. Why do we need to make such changes? This prevents others from obtaining report files in RPT format. The specific content is described in the sample file of the crystal report.
This will allow you to "hide" The Crystal Reports. rpt file in the WEB-INF directory, where it will not be directly browsable by the end user of your application. you cocould also hide them in/WEB-INF/classes or/WEB-INF/lib, or any other directory under WEB-INF, so long as you modify the config file accordingly.
7. Put the report file in the WEB-INF directory, if the report needs to connect to the database in the same directory, copy the database. For example, when using ADO to connect to access in the example, you need to put the access directory.
8. Create a JSP under the webroot directory, for example, basic. jsp. The content is as follows:
<% @ Page Language = "Java" pageencoding = "gb2312" %>
<% @ Page import = "com. crystaldecisions. Reports. reportengineinterface. *" %>
<% @ Page import = "com. crystaldecisions. Report. Web. Viewer. *" %>
<%
Crystalreportviewer CRV = new crystalreportviewer ();
Jpereportsourcefactory jrsf = new jpereportsourcefactory ();
CRV. setreportsource (jrsf. createreportsource ("HR. rpt", request. getlocale ()));
CRV. processhttprequest (request, response, application, null );
%>
The first line is added to enable the report to display text. Change the default UTF Encoding to gb2312 encoding.
9. After the web application is deployed, for example, under tomcat. Open your browser and type: http: // localhost: 8080/<Web Application name>/basic. jsp.

I used to refer to the official tutorials and found that there are still many differences. After being called for more than half a day, I wrote down the entire process. In actual development, it is impossible to use the basic. jsp architecture to write programs. You must call the program in Java code to call the viewer more flexibly.

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.