求水晶报表在JSP中的应用的一些实例?网上找了一下,很少这方面的资料,那位高手做过,能不能给些实例?谢谢!!
------解决方案--------------------
- Java code
我的解决方案:一:下载 crystal reports 10 for BEA weblogic workshop二:安装crystal reports 10 for BEA weblogic workshop;三:如果安装成功,则在C:\Program Files\Common Files\Crystal Decisions\2.5\bin目录下,可以找到CRDB_JavaServer.ini文件.该文件很重要,里面的内容关系到水晶报表如何访问数据库.我的水晶报表采用jdbc的方式访问oracle数据库,配置如下:[Common]PATH = C:\bea\jdk141_05\binCLASSPATH = C:\Projects\Drivers\jdbc\classes12.jar;C:\Projects\Drivers\jdbc\msbase.jar;C:\Projects\Drivers\jdbc\mssqlserver.jar;C:\Projects\Drivers\jdbc\msutil.jar;C:\Projects\Drivers\jdbc\common.jar;C:\Projects\Drivers\jdbc\db2fs.jar;C:\Projects\Drivers\jdbc\db2java.zip;C:\Projects\Drivers\jdbc\db2jcc.jar;C:\Projects\Drivers\jdbc\weblogic.jar;D:/Progra~1/IBM/WebSph~1/Applic~1\v5.1.1\runtimes\base_v51\lib\naming.jar;D:/Progra~1/IBM/WebSph~1/Applic~1\v5.1.1\runtimes\base_v51\lib\namingclient.jar;D:/Progra~1/IBM/WebSph~1/Applic~1\v5.1.1\runtimes\base_v51\lib\namingserver.jar;D:/Progra~1/IBM/WebSph~1/Applic~1\v5.1.1\runtimes\base_v51\lib\cmImpl.jar;D:/Progra~1/IBM/WebSph~1/Applic~1\v5.1.1\runtimes\base_v51\lib\j2cImpl.jar;C:/projects/drivers/jdbc/weblogic.jar;C:\Program Files\Common Files\Crystal Decisions\2.5\bin\CRDBJavaServer.jar;C:\bea\weblogic81\server\lib\ojdbc14.jarIORFileLocation = ${TEMP}JavaServerTimeout = 1800JVMMaxHeap = 64000000JVMMinHeap = 32000000[CRDB_JDBC]CacheRowSetSize = 100JDBCURL = jdbc:oracle:thin:@192.168.1.99:1521:pwsc JNDIURL = JDBCUserName = testuserJDBCDriverName = oracle.jdbc.driver.OracleDriverJNDIUserName = weblogicJNDIConnectionFactory = JNDIInitContext = /GenericJDBCDriverBehavior = DB2[CRDB_XML]PREREADNBYTE = 5000CacheRowSetSize = 100XMLLOCALURL = SCHEMALOCALURL = XMLHTTPURL = SCHEMAHTTPURL = USETEMPFile = TRUE以上是配置文件,需要说明的是:1:由于我采用的是jdbc的方式访问数据库,所以CLASSPATH中一定要把C:\bea\weblogic81\server\lib\ojdbc14.jar加进去,它是jdbc的驱动2:[CRDB_JDBC]中的:JDBCURL = jdbc:oracle:thin:@192.168.1.99:1521:pwsc 是我要访问的数据库名称.JDBCUserName = testuser是设置用户名, JDBCDriverName = oracle.jdbc.driver.OracleDriver是jdbc驱动名称四:在水晶报表编辑器中编辑我要用的报表.由于我需要动态的给报表传递参数,所以我在报表中设置了一个参数字段,水晶报表根据这个参数字段,就可以显示相应的数据,参数字段命名为BH,在公式编辑器中编写如下代码:IF {?BH}<>"" THEN{GG_BPBJ.JLBH}={?BH}ELSE{GG_BPBJ.JLBH}="1" OR {GG_BPBJ.JLBH}<>"1"以上代码的意思是:如果bh参数不为空,则显示{GG_BPBJ.JLBH}等于参数BH的记录,否则显示出所有的记录(大家可能觉得{GG_BPBJ.JLBH}="1" OR {GG_BPBJ.JLBH}<>"1"很可笑,是啊,我开始是写成"true"了,在水晶报表编辑器中可以很好的运行,但方到web上显示就有问题,万般无奈,只有如此了,:( )五:在weblogic workshop中新建一个web项目,用右键选择该项目文件夹,选择"新建",选择"crystal report",则在该web项目根目录下自动新建了一个crystalreportviewers10目录,里面有显示水晶报表需要的页面元素系统自动添加了开发水晶报表需要的jar包,共有13个jar文件(位于WEB_INF\LIB目录下),并增加了一些水晶报表专用的标签(在WEB_INF\SRC下)六:需要特别注意的是:在WEB_INF下的web.xml文件也随之改动,改动后的web.xml文件如下:<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"><!-- The web.xml file is a configuration file used to control the behavior of WebLogic server.In most cases, you will not need to modify this file. For more information on web.xml, pleaseconsult the Web.xml Deployment Descriptor Elements chapter of the "Developing WebLogic ServerApplications" documentation on edocs.bea.com. --><web-app> <display-name>Workshop Application</display-name> <context-param> <param-name>weblogic.httpd.inputCharset./*</param-name> <param-value>GBK</param-value> </context-param> <context-param> <param-name>crystal_image_uri</param-name> <param-value>/webmis/crystalreportviewers10</param-value> </context-param> <filter> <filter-name>PageFlowJspFilter</filter-name> <filter-class>com.bea.wlw.netui.pageflow.PageFlowJspFilter</filter-class> </filter> <filter-mapping> <filter-name>PageFlowJspFilter</filter-name> <url-pattern>*.jsp</url-pattern> </filter-mapping> <listener> <listener-class>com.bea.wlw.runtime.core.servlet.WebappContextListener</listener-class> </listener> <!-- Standard Action Servlet Configuration (with debugging) --> <servlet> <servlet-name>messageServlet</servlet-name> <servlet-class>com.infoearth.servlets.getTaskServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet> <servlet-name>action</servlet-name> <servlet-class>com.bea.wlw.netui.pageflow.DynamicSubappActionServlet</servlet-class> <init-param> <param-name>config</param-name> <param-value>/WEB-INF/jpf-struts-config.xml</param-value> </init-param> <init-param> <param-name>config/-global</param-name> <param-value>/WEB-INF/jpf-struts-config--global.xml</param-value> </init-param> <init-param> <param-name>debug</param-name> <param-value>2</param-value> </init-param> <init-param> <param-name>detail</param-name> <param-value>2</param-value> </init-param> <load-on-startup>2</load-on-startup> </servlet> <servlet> <servlet-name>drawImage</servlet-name> <servlet-class>com.infoearth.drawimage.DrawImageServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>drawImage</servlet-name> <url-pattern>drawImage</url-pattern> </servlet-mapping> <!-- Struts Action Servlet Mappings --> <!-- Note that because Struts takes the *last* mapping here as the extension to add to actions posted from forms, we must have *.do come after *.jpf. --> <servlet-mapping> <servlet-name>action</servlet-name> <url-pattern>*.jpf</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>action</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>messageServlet</servlet-name> <url-pattern>/messageServlet</url-pattern> </servlet-mapping> <mime-mapping> <extension>doc</extension> <mime-type>application/msword</mime-type> </mime-mapping> <mime-mapping> <extension>xls</extension> <mime-type>application/msexcel</mime-type> </mime-mapping> <welcome-file-list> <welcome-file>Login/loginController.jpf</welcome-file> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <error-page> <error-code>500</error-code> <location>/error.jsp</location> </error-page> <!-- Define the NetUI tag library TLDs --> <taglib> <taglib-uri>netui-tags-html.tld</taglib-uri> <taglib-location>/WEB-INF/netui-tags-html.tld</taglib-location> </taglib> <taglib> <taglib-uri>netui-tags-databinding.tld</taglib-uri> <taglib-location>/WEB-INF/netui-tags-databinding.tld</taglib-location> </taglib> <taglib> <taglib-uri>netui-tags-template.tld</taglib-uri> <taglib-location>/WEB-INF/netui-tags-template.tld</taglib-location> </taglib> <taglib> <taglib-uri>/crystal-tags-reportviewer.tld</taglib-uri> <taglib-location>/WEB-INF/crystal-tags-reportviewer.tld</taglib-location> </taglib></web-app>其中: