As described on the Sun Microsystems®web site (http://java.sun.com
), Java servlets provide web developers with a simple, consistent mechanism for extending the functionality of a web server and for accessing existing business systems. A servlet can almost be thought of as an applet that runs on the server side -- without a face. Java Servlets have made many web applications possible.
Today, servlets are a popular choice for building interactive web applications. Servlet containers are available for Apache Web Server, iPlanet Web Server (formerly Netscape Enterprise Server), Microsoft IIS, and others. Servlet containers can also be integrated with web-enabled application servers, such as BEA WebLogic Application Server, IBM WebSphere, Netscape Application Server, and others.
The sections below describe how to set up an example servlet provided with EspressReport (located in EspressReport/help/examples/servlet/StreamingReport
directory). Please note that each section deals specifically with the example servlet. However, they can be used as a guide for setting up and running your own servlets in addition to the other example servlets given.
In addition to this servlet, other servlet examples have also been provided. They range from the simple showing of a report (either in HTML or DHTML format) to the streaming of a report containing charts directly to the browser. Setup and running of these examples can be done using the following sections as a guide:
Make sure that the following files:-
Summary_1.rpt
Summary_2.rpt
CrossTab.rpt
exist in the EspressReport/help/examples/templates
directory.
Make sure the EspressManager is running.
Next, depending on what servlet server (runner) that you are using, follow the guidelines below. Then run index.html
(located in the EspressReport/help/examples/servlet/StreamingReport
directory) from a browser.
Note that even though the instructions refer to the Windows platforms, they can be used for Unix/Linux platforms as well. Changing the file names and path to conform to the Unix/Linux standard is the only necessary step.
The examples all use single threaded model for simplicity's sake. However, EspressReport API can also be used in a multi-threaded environment also.
The following uses the StreamingReport servlet example under EspressReport/help/examples/servlet
.
Please, be sure, that you have Tomcat server in version 5.5.20 or 6.0.10 installed However, this guide is probably also applicable for previous versions of Tomcat server.
There are two installation file versions for Windows operating system (for every version) of ApacheTomcat server:
- uses startup.bat
- installs Windows service and uses “Apache Tomcat Monitor” application
Classpath – You should include ReportDesigner.jar
and servlet-api.jar
files in the classpath.
file can be found in EspressReport/lib
directory
can be found in Tomcat installation directory (apache-tomcat-5.5.20\common\lib\
directory if you use zip installation file; C:\Program Files\Apache Software Foundation\Tomcat 5.5\common\lib\
directory as the default Tomcat installation directory when using exe installation file)
Here is the example classpath setting (using command line console):
set classpath=%classpath%;C:\Program Files\Apache Software Foundation\Tomcat 5.5\common\lib\servlet-api.jar;C:\EspressReport\lib\ReportDesigner.jar
(when using Tomcat 5.5 zip installation file)
set classpath=%classpath%;C:\apache-tomcat-5.5.20\common\lib\servlet-api.jar;C:\EspressReport\lib\ReportDesigner.jar
(when using Tomcat 5.5 installer - exe installation file)
Note | |
---|---|
For Tomcat 6.0 version, please use following: set classpath=%classpath%;C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\servlet-api.jar;C:\EspressReport\lib\ReportDesigner.jar (when using Tomcat 6.0 zip installation file) set classpath=%classpath%;C:\apache-tomcat-6.0.10\lib\servlet-api.jar;C:\EspressReport\lib\ReportDesigner.jar |
(when using Tomcat 6.0 installer - exe installation file)
Note | |
---|---|
Classpath does not necessarily need to be set, but it simplifies |
Note | |
---|---|
You can set Classpath variable also using → → . |
Compiling the example file (streamingReportServlet.java
)
Compile command:
javac -classpath "C:\Program Files\Apache Software Foundation\Tomcat 5.5\common\lib\servlet-api.jar;C:\EspressReport\lib\ReportDesigner.jar" streamingReportServlet.java
(for Tomcat 5.5 version)
javac -classpath "C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\servlet-api.jar;C:\EspressReport\lib\ReportDesigner.jar" streamingReportServlet.java
(for Tomcat 6.0 version)
(if classpath environment variable was not set in step 2 of this guide)
or simply:
javac streamingReportServlet.java
(if classpath was set properly)
Copying to Tomcat’s webapps\ROOT\WEB-INF\classes
directory
Copy streamingReportServlet.class
file to Tomcat’s webapps\ROOT\WEB-INF\classes
directory.
Note | |
---|---|
Please note that |
Adding necessary libraries for running the servlet to lib dir
In order to run the example, you also need to add libraries to Apache Tomcat’s webapps\ROOT\WEB-INF\lib
directory. Please copy ReportDesigner.jar
file placed in EspressReport\lib directory to the webapps\ROOT\WEB-INF\lib
directory.
Note | |
---|---|
Please note that the |
Registering your servlet appplication in web.xml
file of your Tomcat server.
Before you can run your servlet application, you need to modify web.xml
file that is placed in webapps\ROOT\WEB-INF\
directory of your Tomcat server.
For registering streamingReportServlet
, please add the following code:
<servlet> <servlet-name>streamingReportServlet</servlet-name> <servlet-class>streamingReportServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>streamingReportServlet</servlet-name> <URL-pattern>/servlet/streamingReportServlet</URL-pattern> </servlet-mapping>
between <web-app>
and </web-app>
xml tags.
Note | |
---|---|
When using Tomcat in version 5.5.20, you can also enable This is intended only for test purposes. Using the invoker servlet in a production environment is not recommended and is unsupported. |
Start (restart) the Tomcat Server
If you used zip installation file, please run startup.bat
(startup.sh
for Linux) file from bin directory of Tomcat installation directory.
For exe installation files you need to startup the Tomcat service. You can use Tomcat’s “Monitor Tomcat ”application for this purpose.
Note | |
---|---|
If your Tomcat server is already running, you probably need to restart it(shutdown and startup again) to make the example runnable. |
Running the example
The last step is running the example. To run the example, please run index.html
file placed in EspressReport\help\examples\servlet\StreamingReport
directory in your browser.
After clicking the streamingReportServlet
is called and appropriate report is generated.
Note | |
---|---|
Please be sure, that EspressManager is running before you run the example. If it is not running, empty report is generated. |
Note | |
---|---|
Please note that the servlet as designed and given will only work if both the servlet runner and the client browser are on the same machine. To allow the client to be on a different machine, modify the line in from: <form action="http://127.0.0.1:8080/servlet/streamingReportServlet" method="post"> to: <form action="http://<machine_name>:8080/servlet/streamingReportServlet" method="post"> |
Note | |
---|---|
If you use Automatic settings discovery in your web browser, there can be problem reaching Please use <form action="http://localhost:8080/servlet/streamingReportServlet" method="post"> |
Replace the machine name and port number in Servlet.html
file to
<FORM ACTION=http://<machine name>:8100/servlet/streamingReportServlet method=POST>
Log into the JRun Default Server Administrator.
Click on
and then .Add the path to ReportAPIWithChart.jar
and click on .
Restart the JRun Default Server.
Compile the servlet and copy it to <jrun_installation_directory>/servers/default/default-app/WEB-INF/classes
.
Replace all html files with.cfm extensions (For example, Servlet.html
becomes Servlet.cfm
) and replace the machine name and port number in the cfm file to
<FORM ACTION=http://<machine name>:8100/servlet/streamingReportServlet method=POST>
Log into the JRun Default Server Administrator.
Click on
and then .Add the path to ReportAPIWithChart.jar
and click on .
Restart the JRun Default Server.
Compile the servlet and copy it to <jrun_installation_directory>/servers/default/default-app/WEB-INF/classes
.
To set up and run the servlet example, first, go to the wlserver6.0\config\examples
directory. Modify both setExamplesEnv.cmd
and startExamplesServer.cmd
files according to the following instructions:
Add set ES_REPORT=<directory where EspressReport is installed>
in the @rem Set user-defined variables
section. The ES_REPORT
variable contains the path to the EspressReport Home directory in your machine. Modify the path value to correspond to the path in your machine. Also, please make sure the WL_HOME
and JAVA_HOME
variables correspond to the correct paths on your computer.
Add %ES_REPORT%\lib\ReportAPIWithChart.jar;
. to the set CLASSPATH field of the same file.
Put the html files in the wlserver6.0\config\examples\applications\examplesWebApp
directory.
Change the machine name in the code from 127.0.0.1:8080
to <machineName>:7001
in the Servlet.html
file.
Put the streamingReportServlet.java
in the wlserver6.0\samples\examples\servlets
directory.
Insert the following code fragments in the web.xml
file located in the wlserver6.0\config\examples\applications\examplesWebApp\WEB-INF\
directory. The <servlet>
code would go in the <servlet>
code section in the file and in the <servlet-mapping>
section.
<servlet> <servlet-name>streamingReportServlet</servlet-name> <servlet-class>streamingReportServlet</servlet-class> <init-param> <param-name>reportType</param-name> <param-value>Summary</param-value> <param-name>rowBreaks</param-name> <param-value>ProductType</param-value> <param-name>browser</param-name> <param-value>Netscape</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>streamingReportServlet</servlet-name> <URL-pattern>/streamingReportServlet/*</URL-pattern> </servlet-mapping>
In a command prompt window, go to the wlserver6.0\config\examples
directory and run setExamplesEnv
.
Then, go to wlserver6.0\samples\examples\servlets
directory and compile streamingReportServlet.java
separately using the command lines listed below.
javac –d %EX_WEBAPP_CLASSES% streamingReportServlet.java
In the same command prompt window, go back to wlserver6.0\config\examples
directory and start the WebLogic server by typing startExamplesServer
and pressing the Enter key.
Open your web browser and go to http://yourMachineName:7001/ examplesWebApp/index.html
to view the servlet example.
The following instructions show how to set up and run the servlet example under WebLogic 9.2. The instructions assume that you have WebLogic 9.2 server installed on the system. The location of the WebLogic installation will be referenced as <WL_INSTALL_DIR>
and the location of the EspressReport installation will be referenced as <ER_INSTALL_DIR>
.
To set up and run the servlet example, first, go to the <WL_INSTALL_DIR>/samples/domains/wl_server/bin
directory. Modify the setExamplesEnv.cmd
file according to the following instructions.
Add set ES_REPORT=<ER_INSTALL_DIR>
. The ES_REPORT
variable contains the path to the EspressReport Home directory in your machine. Modify the path value to correspond to the path in your machine. Also, please make sure the WL_HOME
and JAVA_HOME
variables correspond to the correct paths on your computer.
Add %ES_REPORT%\lib\ReportAPIWithChart.jar;%ES_REPORT%\lib\qblicense.jar;
to the set CLASSPATH field of the same file.
Next, follow the steps below (note that the files are under <ER_INSTALL_DIR>\help\examples\servlet\StreamingReport
directory):
Put the html files (columnar.html
, servlet.html
, index.html
) to the <WL_INSTALL_DIR>\samples\server\examples\build\examplesWebApp
directory.
Edit the servlet.html
file and change the machine name in code from 127.0.0.1:8080/servlet
to yourmachineName:7001/examplesWebApp
.
Put the streamingReportServlet.java
file in the <WL_INSTALL_DIR>\samples\server\examples\build\examplesWebApp\WEB-INF\classes
directory.
Insert the following code fragments in the web.xml
file located in the <WL_INSTALL_DIR>\samples\server\examples\build\examplesWebApp\WEB-INF
directory. The <servlet>
code would go in the <servlet>
code section in the file and <servlet-mapping>
in the <servlet-mapping>
section.
<servlet> <servlet-name>streamingReportServlet</servlet-name> <servlet-class>streamingReportServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>streamingReportServlet</servlet-name> <URL-pattern>/streamingReportServlet/*</URL-pattern> </servlet-mapping>
Then, go to <WL_INSTALL_DIR>\samples\server\examples\build\examplesWebApp\WEB-INF\classes
directory and compile streamingReportServlet.java
. Please includeReportAPIWithChart.jar
and javax.servlet.jar
in the classpath (Note: javax.servlet.jar
is located under bea\jrockit90_150_06\mercuryprofiler\lib
directory).
In a command prompt window, go back to <WL_INSTALL_DIR>/samples/domains/wl_server
directory and start the WebLogic server by typing startWebLogic.cmd
and pressing the Enter key.
Open your web browser and go to http://yourMachineName:7001/examplesWebApp/index.html
to view the servlet example.
Note | |
---|---|
For troubleshooting, please check for typing errors. |
Open the WebSphere Administrator's Console and under the Advanced tab and add ReportAPIWithChart.jar
to the Classpath. Then click on .
Modify the FORM ACTION
tag in Servlet.html
to the following:
<FORM ACTION=http://<machine name>/servlet/streamingReportServlet method=POST>
Compile streamingReportServlet.java
and move the class file to the WebSphere/AppServer/servlets
directory.
Start/Restart the Default Server under the node.
The following instructions show how to set up and run the servlet example under WebSphere 6.1. The instructions assume that you have WebSphere 6.1 server installed on the system. The location of the WebSphere installation will be referenced as <WS_INSTALL_DIR>
and the location of the EspressReport installation will be referenced as <ER_INSTALL_DIR>
.
To set up and run the servlet example, first, copy <ER_INSTALL_DIR>\lib\ReportAPIWithChart.jar
and <ER_INSTALL_DIR>\lib\qblicense.jar
files to the <WS_INSTALL_DIR>\AppServer\lib
directory.
Next, follow the steps below (note that the files are under <ER_INSTALL_DIR>\help\examples\servlet\StreamingReport
directory):
Put the streamingReportServlet.java
file in the <WS_INSTALL_DIR>\AppServer\profiles\AppSrv01\installedApps\<YourMachineName>Node01Cell\ivtApp.ear\ivt_app.war\WEB-INF\classes
directory.
Edit the servlet.html
file and change the machine name in code from 127.0.0.1:8080/servlet
to yourmachineName:9080/ivt/servlet
.
Put the html files (columnar.html
, servlet.html
, index.html
) to the <WS_INSTALL_DIR>\AppServer\profiles\AppSrv01\installedApps\<YourMachineName>Node01Cell\ivtApp.ear\ivt_app.war
directory.
Insert the following code fragments in the web.xml
file located in the <WS_INSTALL_DIR>\AppServer\profiles\AppSrv01\installedApps\<YourMachineName>Node01Cell\ivtApp.ear\ivt_app.war\WEB-INF
directory. The <servlet>
code would go in the <servlet>
code section in the file and <servlet-mapping>
in the <servlet-mapping>
section.
<servlet> <servlet-name>streamingReportServlet</servlet-name> <servlet-class>streamingReportServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>streamingReportServlet</servlet-name> <URL-pattern>streamingReportServlet</URL-pattern> </servlet-mapping>
Then, go to <WS_INSTALL_DIR>\AppServer\profiles\AppSrv01\installedApps\<YourMachineName>Node01Cell\DefaultApplication.ear\DefaultWebApplication.war\WEB-INF\classesdirectory
and compile streamingReportServlet.java
. Please include ReportAPIWithChart.jar
and j2ee.jar
in the classpath (Note: j2ee.jar is located under <WS_INSTALL_DIR>\AppServer\lib
directory).
Start the WebSphere server. There are several ways to do this. The easiest way for Windows users is to launch the First Steps tool from → → → → → → . You can also launch the administration console from the First Steps tool.
Open your web browser and go to http://yourMachineName:9080/ivt/index.html
to view the servlet example.
Note | |
---|---|
For troubleshooting please check for typing errors. |
Go to
→ → .Enter in the name of the project in the Project Name text-field. For our example, we will use EspressReport
.
Click on the
button.Go to the EspressReport project folder in the J2EE Navigator panel and expand the project folder.
Right click on the Java Source sub-folder and choose the Import option. Choose the File System type import.
Import the Java source files for your servlets and java beans here. For this example, import streamingReportServlet.java
from the EspressReport/help/examples/servlet/StreamingReport
directory.
Go back to the EspressReport project folder.
Go to the Web Content sub-folder. Import JSP and HTML files here. For this example, choose the File System type import and import index.html
, Columnar.html
" and Servlet.html
files from EspressReport/help/examples/servlet/StreamingReport
directory.
Go to the WEB-INF/lib
sub-folder and right click to the Import option and import ExportLib.jar
and ReportAPIWithChart.jar
files from the EspressReport/lib
directory.
Double-click and open the Servlet.html
file and hit the Source tab to edit.
Modify the FORM ACTION
tag in Servlet.html
to the following:
<FORM ACTION=http://<machine name>:7080/EspressReport/servlet/streamingReportServlet method=POST>
where 7080
is the HTTP port number. If 7080
is not the port number, substitue the appropriate value.
Save this HTML file.
Right-click on the EspressReport web project folder and choose Rebuild Project.
Right-click on the EspressReport web project folder and choose Run on Server... .
Choose the server and click on the
button. It is recommended that you choose a server that has already been configured.The results will be showin in a Web Browser panel.
The following instructions show how to set up and run the servlet example under JBoss 4.0.5.The instructions assume that you have JBoss 4.0.5 server installed on the system. The location of the JBoss 4.0.5 installation will be referenced as <JB_INSTALL_DIR>
and the location of the EspressReport installation will be referenced as <ER_INSTALL_DIR>
.
To set up and run the servlet example, first, go to the <JB_INSTALL_DIR>\bin
directory. Modify the run.bat
file according to the following instructions:
Add set ES_REPORT=<ER_INSTALL_DIR>
. The ES_REPORT
variable contains the path to the EspressReport Home directory in your machine.
Add %ES_REPORT%\lib\ReportAPIWithChart.jar;%ES_REPORT%\lib\qblicense.jar;
to the set JBOSS_CLASSPATH
field of the same file.
Next, follow the steps below (note that the files are under <ER_INSTALL_DIR>\help\examples\servlet\StreamingReport
directory):
Put the streamingReportServlet.java
file in the <JB_INSTALL_DIR>\server\default\deploy\jmx-console.war\WEB-INF\classes
directory.y
Edit the servlet.html
file and change the machine name in code from 127.0.0.1:8080/servlet
to yourmachineName:8080/jmx-console
in the servlet.html
file.
Put the html files (columnar.html
, servlet.html
and index.html
) to the <JB_INSTALL_DIR>\server\default\deploy\jmx-console.war
directory.
Insert the following code fragments in the web.xml
file located in the <JB_INSTALL_DIR>\server\default\deploy\jmx-console.war\WEB-INF
directory. The <servlet>
code would go in the <servlet>
code section in the file and <servlet-mapping>
in the <servlet-mapping>
section.
<servlet> <servlet-name>streamingReportServlet</servlet-name> <servlet-class>streamingReportServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>streamingReportServlet</servlet-name> <URL-pattern>/streamingReportServlet</URL-pattern> </servlet-mapping>
Then, go to <JB_INSTALL_DIR>\server\default\deploy\jmx-console.war\WEB-INF\classes
directory and compile ExportServlet2.java
. Please include ReportAPIWithChart.jar
and javax.servlet.jar
in the classpath (Note: javax.servlet.jar
is located under <JB_INSTALL_DIR>\server\all\lib
directory).
In a command prompt window, go to <JB_INSTALL_DIR>\bin
directory and start the JBoss server by typing run.bat
and pressing the Enter key.
Open your web browser and go to http://yourMachineName:8080/jmx-console/index.html
to view the servlet example.
Note | |
---|---|
For troubleshooting, please check for typing errors. |
The following instructions show how to set up and run the servlet example under Orion 2.0.7. The instructions assume that you have Orion 2.0.7 server installed on the system. The location of the Orion installation will be referenced as <OR_INSTALL_DIR>
and the location of the EspressReport installation will be referenced as <ER_INSTALL_DIR>
.
Follow the steps below (note that the files are under <ER_INSTALL_DIR>\help\examples\servlet\StreamingReport
directory):
Put the streamingReportServlet.java
file in the <OR_INSTALL_DIR>\default-web-app\WEB-INF\classes
directory.
Edit the servlet.html
file and change the part of URL in code from 127.0.0.1:8080/servlet
to yourmachineName:80
.
Rename the index.html
file to index2.html
and put the html files (columnar.html
, servlet.html
and index2.html
) to the <OR_INSTALL_DIR>\default-web-app
directory.
Insert the following code fragments in the web.xml
file located in the <OR_INSTALL_DIR>\default-web-app\WEB-INF
directory. The <servlet>
code would go in the <servlet>
code section in the file and <servlet-mapping>
in the <servlet-mapping>
section.
<servlet> <servlet-name>streamingReportServlet</servlet-name> <servlet-class>streamingReportServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>streamingReportServlet</servlet-name> <URL-pattern>streamingReportServlet</URL-pattern> </servlet-mapping>
Then, go to <OR_INSTALL_DIR>default-web-app\WEB-INF\classes
directory and compile streamingReportServlet.java
. Please include ReportAPIWithChart.jar
and j2ee.jar
in the classpath (Note: You can use j2ee.jar from the J2eeSDK installation located under <J2EE_SDK_INSTALL_DIR>\lib
directory).
Copy the ReportAPIWithChart.jar
and qblicense.jar
files to the <OR_INSTALL_DIR>\bin
directory.
In a command prompt window, go to <OR_INSTALL_DIR>
directory and start the Orion server by typing java -jar orion.jar
and pressing the Enter key.
Open your web browser and go to http://yourMachineName:80/index2.html
to view the servlet example.
Note | |
---|---|
For troubleshooting, please check for typing errors. |
The following instructions show how to set up and run the servlet example under JRun 4 (with Update 6). The instructions assume that you have JRun server installed on the system. The location of the JRun installation will be referenced as <JR_INSTALL_DIR>
and the location of the EspressReport installation will be referenced as <ER_INSTALL_DIR>
.
Follow the steps below (note that the files are under <ER_INSTALL_DIR>\help\examples\servlet\StreamingReport
directory):
Edit the servlet.html
file and change the part of URL in code from 127.0.0.1:8080
to yourmachineName:8100
.
Put the html files (columnar.html
, servlet.html
and index.html
) in the <JR_INSTALL_DIR>\servers\default\default-ear\default-war
directory.
Put the streamingReportServlet.java
file in the <JR_INSTALL_DIR>\servers\default\default-ear\default-war\WEB-INF\classes
directory.
Insert the following code fragments in the web.xml
file located in the <JR_INSTALL_DIR>\servers\default\default-ear\default-war\WEB-INF
directory. The <servlet>
code would go in the <servlet>
code section in the file and <servlet-mapping>
in the <servlet-mapping>
section.
<servlet> <servlet-name>streamingReportServlet</servlet-name> <servlet-class>streamingReportServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>streamingReportServlet</servlet-name> <URL-pattern>/servlet/streamingReportServlet</URL-pattern> </servlet-mapping>
Then, go to <JR_INSTALL_DIR>\servers\default\default-ear\default-war\WEB-INF\classes
directory and compile streamingReportServlet.java
. Please include ReportAPIWithChart.jar
and j2ee.jar
in the classpath (Note: You can use j2ee.jar
from the J2eeSDK installation located under <J2EE_SDK_INSTALL_DIR>\lib
directory).
Copy the ReportAPIWithChart.jar
and qblicense.jar
files to the <JR_INSTALL_DIR>\servers\lib
directory.
Start the JRun 4 application server by executing <JR_INSTALL_DIR>\bin\jrun.exe
. This will launch the JRun Launcher window.From JRun Launcher, start default server.
Open your web browser and go to http://yourMachineName:8100/index.html
to view the servlet example.
Note | |
---|---|
For troubleshooting, please check for typing errors. |
The following instructions show how to set up and run the servlet example under Oracle 10g (10.1.3.1.0).The instructions assume that you have Oracle 10g (10.1.3.1.0) server installed on the system. The location of the Oracle 10g installation will be referenced as <ORA_INSTALL_DIR>
and the location of the EspressReport installation will be referenced as <ER_INSTALL_DIR>
.
Follow the steps below (note that the files are under <ER_INSTALL_DIR>\help\examples\servlet\StreamingReport
directory):
Edit the servlet.html
file and change the part of URL in code from 127.0.0.1:8080
to yourMachineName:8888
.
Rename the index.html
file to index2.html
and put the html files (columnar.html
, servlet.html
and index2.html
) in the <ORA_INSTALL_DIR>\j2ee\home\default-web-app
directory.
Put the streamingReportServlet.java
file in the <ORA_INSTALL_DIR>\j2ee\home\default-web-app\WEB-INF\classes
directory.
Insert the following code fragments in the web.xml
file located in the <ORA_INSTALL_DIR>\j2ee\home\default-web-app\WEB-INF
directory. The <servlet>
code would go in the <servlet>
code section in the file and <servlet-mapping>
in the <servlet-mapping>
section.
<servlet> <servlet-name>streamingReportServlet</servlet-name> <servlet-class>streamingReportServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>streamingReportServlet</servlet-name> <URL-pattern>/servlet/streamingReportServlet</URL-pattern> </servlet-mapping>
Then, go to <ORA_INSTALL_DIR>\j2ee\home\default-web-app\WEB-INF\classes
directory and compile streamingReportServlet.java
. Please include ReportAPIWithChart.jar
and servlet.jar
in the classpath (Note: The servlet.jar
is located under <ORA_INSTALL_DIR>\j2ee\home\lib
directory).
Copy the ReportAPIWithChart.jar
and qblicense.jar
files to the <ORA_INSTALL_DIR>\j2ee\home\applib
directory.
Start the Oracle server. The easiest way for Windows users is to launch the Start Soa suite from → → → . You can also launch the Oracle server by executing runstartupconsole.bat
under the <ORA_INSTALL_DIR>\j2ee\home\bin
directory.
Open your web browser and go to http://yourMachineName:8888/index2.html
to view the servlet example.
Note | |
---|---|
For troubleshooting, please check for typing errors. |
The following instructions show how to set up and run the servlet example under Sun Java System Application PE (9.0 or 8.2). The instructions assume that you have Sun Java System Application PE server installed on the system. The location of the Sun App Server installation will be referenced as <SAP_INSTALL_DIR>
and the location of the EspressReport installation will be referenced as <ER_INSTALL_DIR>
.
First, create your own directory. The location of the directory will be referenced as <USER_DIR>
.
Then, go to the <SAP_INSTALL_DIR>\samples\quickstart
directory and copy the hello.war
file to the <USER_DIR>
directory. Next unpack the hello.war file. Note: In order to unpack the war file, you can use jar or unzip. For unpacking using jar, first, make sure that the java\bin
directory is in your path and then execute the following command jar -xf hello.war
in the <USER_DIR>
directory.
Follow the steps below (note that the files are under <ER_INSTALL_DIR>\help\examples\servlet\StreamingReport
directory):
Edit the servlet.html
file and change the part of URL in code from 127.0.0.1:8080/servlet
" to yourMachineName:8080/hello/servlet
.
Put the html files (columnar.html
, servlet.html
and index.html
) in the <USER_DIR>
directory.
Put the streamingReportServlet.java
file in the <USER_DIR>\WEB-INF\classes
directory.
Insert the following code fragments in the web.xml
file located in the <USER_DIR>\WEB-INF
directory.
<servlet> <servlet-name>streamingReportServlet</servlet-name> <servlet-class>streamingReportServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>streamingReportServlet</servlet-name> <URL-pattern>/servlet/streamingReportServlet</URL-pattern> </servlet-mapping>
Then, go to <USER_DIR>\WEB-INF\classes
directory and compile streamingReportServlet.java
. Please include ReportAPIWithChart.jar
and j2ee.jar
in the classpath (Note: The j2ee.jar
file is located under <SAP_INSTALL_DIR>\lib
directory).
Navigate to the <USER_DIR>
directory in command window and then create a war file by executing the following command: jar -cvf hello.war *
.
Move the hello.war
file to the <SAP_INSTALL_DIR>\domains\domain1\autodeploy
directory.
Copy the ReportAPIWithChart.jar
and qblicense.jar
files to the <SAP_INSTALL_DIR>\domains\domain1\lib\applibs directory
.
Start the Sun App server by executing <SAP_INSTALL_DIR>\bin\asadmin start-domain domain1
. The easiest way for Windows users is to launch the Start Default Server from → → → .
Open your web browser and go to http://yourMachineName:8080/hello/index.html
to view the servlet example.
Note | |
---|---|
Note: For troubleshooting, please check for typing errors. |
The following instructions show how to set up and run the servlet example under Sun Java System WebServer 7.0. The instructions assume that you have Sun Java System WebServer 7.0 installed on the system. The location of the Sun WebServer installation will be referenced as <SWS_INSTALL_DIR>
and the location of the EspressReport installation will be referenced as <ER_INSTALL_DIR>
.
First, create your own directory. The location of the directory will be referenced as <USER_DIR>
.
Then, go to the <SWS_INSTALL_DIR>\samples\java\webapps\simple
directory and copy the webapps-simple.war
file to the <USER_DIR>
directory. Next unpack the webapps-simple.war
file.
Note | |
---|---|
In order to unpack the war file, you can use jar or unzip. For unpacking using jar, firstly, make sure that the |
Follow the steps below (note that the files are under <ER_INSTALL_DIR>\help\examples\servlet\StreamingReport
directory):
Edit the servlet.html
file and change the part of URL in code from 127.0.0.1:8080/servlet
to yourMachineName:81/webapps-simple/servlet
.
Rename the index.html
file to index2.html
and put the html files (columnar.html
, servlet.html
and index.html
) in the <USER_DIR>
directory.
Put the streamingReportServlet.java
file in the <USER_DIR>\WEB-INF\classes
directory.
Insert the following code fragments in the web.xml
file located in the <USER_DIR>\WEB-INF
directory. The <servlet>
code would go in the <servlet>
code section in the file and <servlet-mapping>
in the <servlet-mapping>
section.
<servlet> <servlet-name>streamingReportServlet</servlet-name> <servlet-class>streamingReportServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>streamingReportServlet</servlet-name> <URL-pattern>/servlet/streamingReportServlet</URL-pattern> </servlet-mapping>
Then, go to <USER_DIR>\WEB-INF\classes
directory and compile ExportServlet2.java
. Please include ReportAPIWithChart.jar
and j2ee.jar
in the classpath (Note: You can use j2ee.jar
from the J2eeSDK installation located under <J2EE_SDK_INSTALL_DIR>\lib
directory).
Navigate to the <USER_DIR>
directory in command window and create a war file by executing the following command: jar -cvf webapps-simple.war *
.
Copy the ReportAPIWithChart.jar
and qblicense.jar
files to the <SWS_INSTALL_DIR>\https-yourMachineName\lib
directory.
Start the administration server by executing <SWS_INSTALL_DIR>\admin-server\bin\startserv.bat
. After that start your web browser and go to the Admin Console page http://yourMachineName:8989
. From the Admin Console page, log in the administration server and click the Add web application link in the Virtual Server tasks. This will bring you to the Add Web Application window.
From the Add Web Application window, click the <USER_DIR>/webapps-simple.war
file. Specify the URI ( by default: /webapps-simple
) that represents application's context root and is relative to server host. Next, click the button.
From the next screen you should see the webapps-simple application enabled. Click the Deployment Pending warning link in the upper right corner of the screen. Click the link and push the button.
button. After that you will see theIf the deployment was successful you will see the Results window that will inform you: "The configuration has been deployed successfully to all available nodes".
Open your web browser and go to http://yourMachineName:81/webapps-simple/index2.html
to view the servlet example.
Note | |
---|---|
For troubleshooting, please check for typing errors. |
The following instructions show how to set up and run the servlet example under Resin 3.1.0. The instructions assume that you have Resin 3.1.0 installed on the system. The location of the Resin installation will be referenced as <RES_INSTALL_DIR>
and the location of the EspressReport installation will be referenced as <ER_INSTALL_DIR>
.
First, create your own directory. The location of the directory will be referenced as <USER_DIR>
.
Then, go to the <RES_INSTALL_DIR>\webapps
directory and copy the resin-doc.war
file to the <USER_DIR>
directory. Next, unpack the resin-doc.war
file.
Note | |
---|---|
In order to unpack the war file, you can use jar or unzip. For unpacking using jar, make sure that the |
Navigate to the <USER_DIR>\tutorial
directory and copy the servlet-hello
directory to the <RES_INSTALL_DIR>\webapps
. Next rename the servlet-hello
directory to test
.
Follow the steps below (note that the files are under <EC_INSTALL_DIR>\help\examples\servlet\DataFile
directory):
Edit the servlet.html
file and change the part of URL in code from 127.0.0.1:8080/servlet
to yourMachineName:8080/test/servlet
.
Put the html files (columnar.html
, servlet.html
and index.html
) in the <RES_INSTALL_DIR>\webapps\test
directory.
Put the streamingReportServlet.java
file in the <RES_INSTALL_DIR>\webapps\test\WEB-INF\classes
directory.
Insert the following code fragments in the resin-web.xml
file located in the <RES_INSTALL_DIR>\webapps\test\WEB-INF
directory.
<servlet-name="streamingReportServlet" servlet-class="streamingReportServlet"/>
<servlet-mapping URL-pattern="/servlet/streamingReportServlet" servlet-name="streamingReportServlet"/>
Then, go to <RES_INSTALL_DIR>\webapps\test\WEB-INF\classes
directory and compile streamingReportServlet.java
. Please include ReportAPIWithChart.jar
and j2ee.jar
in the classpath (Note: You can use j2ee.jar
from the J2eeSDK installation located under <J2EE_SDK_INSTALL_DIR>\lib
directory).
Copy the ReportAPIWithChart.jar
and qblicense.jar
files to the <RES_INSTALL_DIR>\lib
directory.
Start the Resin server by executing httpd.exe
under the <RES_INSTALL_DIR>
directory.
Open your web browser and go to http://yourMachineName:8080/test/index.html
to view the servlet example.
Note | |
---|---|
For troubleshooting, please check for typing errors. |
The following instructions show how to set up and run the servlet example under ColdFusion MX 7.02. The instructions assume that you have ColdFusion MX 7 application server installed on the system. The location of the ColdFusion MX 7.02 installation will be referenced as <CF_INSTALL_DIR>
and the location of the EspressReport installation will be referenced as <ER_INSTALL_DIR>
.
Follow the steps below (note that the files are under <ER_INSTALL_DIR>\help\examples\servlet\StreamingReport
directory):
Edit the servlet.html
file and change the part of URL in code from 127.0.0.1:8080
to yourmachineName:8500
.
Put the html files (columnar.html
, servlet.html
and index.html
) in the <CF_INSTALL_DIR>\wwwroot
directory.
Put the streamingReportServlet.java
file in the <CF_INSTALL_DIR>\wwwroot\WEB-INF\classes
directory.
Insert the following code fragments in the web.xml
file located in the <CF_INSTALL_DIR>\wwwroot\WEB-INF
directory. The <servlet>
code would go in the <servlet>
code section in the file and <servlet-mapping>
in the <servlet-mapping>
section.
<servlet> <servlet-name>streamingReportServlet</servlet-name> <servlet-class>streamingReportServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>streamingReportServlet</servlet-name> <URL-pattern>/servlet/streamingReportServlet</URL-pattern> </servlet-mapping>
Then, go to <CF_INSTALL_DIR>\wwwroot\WEB-INF\classes
directory and compile streamingReportServlet.java
. Please include ReportAPIWithChart.jar
and j2ee.jar
in the classpath
Note | |
---|---|
You can use |
Copy the ReportAPIWithChart.jar
and qblicense.jar
files to the <CF_INSTALL_DIR>\runtime\lib
directory.
Start ColdFusion application server. For Windows platforms,the ColdFusion application server is installed to run as a service. It should be started automatically. If the server is not running, navigate to the Windows Services and start the ColdFusion MX 7 Application server
service. Re-start the application server, if necessary.
Open your web browser and go to http://yourMachineName:8500/index.html
to view the servlet example.
Note | |
---|---|
For troubleshooting, please check for typing errors. |
Java Server Pages allows the separation of the dynamic content from the static HTML. JSPs allow HTML to be written in the traditional manner and then the code for the dynamic content is enclosed within the HTML within special tags, which usually start with "<%" and end with
%>
The JSPs can be placed along with regular HTML files and they look like HTML files in many ways. However, at run time, JSPs get converted into normal servlets while the static HTML pages are printed.
Java Server Pages are basically an extension of the Servlet technology. However, there is one very big advantage in using JSPs. Java Server Page technology separates the user interface from content generation enabling designers to change the overall page layout without altering the underlying dynamic content.
EspressReport provides a few JSP examples. The example we will be looking at EspressReport/help/examples/jsp/StreamingReport
. This example can also be used as a guide to run the other JSP examples as well as your own JSP code.
Please include ReportAPIWithChart.jar
and servlet.jar
in the classpath. For instance,
set classpath=c:\EspressReport\lib\ReportAPIWithChart.jar;c:\Apache Tomcat 4.0\common\lib\servlet.jar;
Create a subdirectory called report under webapps\ROOT\
. Therefore, if Tomcat is installed under c:\Apache Tomcat 4.0
, you now have a new directory c:\Apache Tomcat 4.0\webapps\ROOT\report
.
Copy StreamingReport.jsp
, and streamerror.jsp
to the webapps/ROOT/report
directory.
Create another directory, also called report under the webapps/ROOT/WEB-INF/classes
directory. Thus, you now have c:\Apache Tomcat 4.0\webapps\ROOT\WEB-INF\classes\report
.
Place the file CreateStreamingReport.java
in the c:\Apache Tomcat 4.0\webapps\ROOT\WEB-INF\classes\report
directory.
Compile CreateStreamingReport.java
. CreateStreamingReport.class
should now exist in the same directory.
Start the Tomcat server. (Run startup.bat
) and start EspressManager.
Open a web browser and go to http://yourMachineName:8080/report/StreamingReport.jsp
(just substitute your actual machine name for yourMachineName).
Specify the options that you want and then submit to get a report in return.
Add ReportAPIWithChart.jar
to the Dependent Classpath under the node (usually called by the machine name).
Click on the Create a Web Application.
button on the toolbar (the last button) and selectEnter Quadbase
(without the quotes) as the name of the web application. Make sure to check the Enable File Servlet option and check Server Servlet by classname and click on .
Choose Default Servlet Engine as the node (keep expanding the tree untill you can select the Default Servlet Engine) and click on .
Change the Web Application Web Path to /Quadbase
and click on .
Add ReportAPIWithChart.jar
to the Classpath.
Note the document root and add it to the Classpath (you will need to create the directory for this path if it does not exist) and click on
.Restart the Default Server.
Create a directory under your web server's document root called Quadbase
(make sure the path matches the Web Applications document root) and move the .jsp files and the Java file there.
Modify CreateStreamingReport.java
to remove (or comment out) the package and compile the Java file. The class file should be in the document root.
Modify the .jsp files to replace report.CreateStreamingReport with CreateStreamingReport.
Start your browser and open http://<machine name>/Quadbase/StreamingReport.jsp
. Input the parameters and click on the button to get the report. Make sure you replace the <machine name>
with a host alias setting found in WebSphere admin console.
You can use both servlets and JSPs to return a report back to the browser. The report can either be shown in a JNLP (More about Applets in JNLP: Section 1.2.7 - Run Applets in WebStart with JNLP file) (i.e., it can be interactive) or be shown in a static format (i.e., HTML, DHTML, PDF). Net traffic and bandwidth availability should be the key factors in deciding whether to use JNLP (More about Applets in JNLP: Section 1.2.7 - Run Applets in WebStart with JNLP file) or static formats.
The reports returned to the browsers can be done in two ways: they can be saved to a file or sent directly to the browser. In the first scenario, the report is saved on the server side and the file location is sent to the client browser which then shows the report.&bsp; In the second scenario, the report itself is sent as an output stream to the client browser.
Servlets and JSPs can save reports to files if the reports shown need to be re-used or a copy is needed. Here, the reports are saved to a file on the server side (whether the report is shown in an applet or in a static format is immaterial). However, these types of servlets and JSPs need to be constructed carefully. If multiple clients hit the page, it is possible for one client to see another client's report. And the browsers might sometimes cache a previous report (in the case of a static format) and will not show the new report unless refreshed/reloaded again. Also, since the files are saved on the server side, care must be taken that the files are not overridden before the client browser has seen the report. Reports should also be purged periodically to avoid taking up server space.
In both cases, a report is exported to the desired format.
QbReport report = new QbReport (...........); .... .... .... int format = QbReport.RPT; // Here set to an interactive format. For a static format change to QbReport.HTML report.export(format, "report");
A HTML file can then be returned to the browser which contains the report location within the HTML file so that the browser can view it.
<applet code="quadbase.reportdesigner.ReportViewer.Viewer.class" width=100% height=100% archive="http://<machineName>/EspressReport/lib/ReportViewer.jar"> <PARAM name="filename" value="report.rpt"> </applet>
Report Viewer has been used here. Please note that when using Report Viewer in the above code, EspressManager MUST be running.
In the case of a static format, calling the HTML file (or providing a link to the PDF file within a HTML file) is sufficient to display the report.
Using this method, you can separate the pages returning the report from your servlet or JSP and design them well in advance and outside of your servlet or JSP. You can use a database or a hashtable to keep track of the reports generated and show them again as needed, as well as have the reports periodically re-generated.
To see an example of a servlet saving the report as a HTML or DHTML file on the server side, please go to EspressReport/help/examples/servlet/Report
.
When you export reports containing charts in HTML or DHTML format, you MUST use the method setHTMLParameters
to set the directory the charts have to be exported to, the http URL mapped to that directory and to set the name of the export chart. Thus in the exported report, <img src>
tags point to the URL and file name specified (with extensions).
For example, given a report with three charts in it and the following method call:
reportChartObject.setHTMLParameters("D:/inetpub/wwwroot/EspressReport/chartimages/", "http://<machine name>/EspressReport/chartimages/", "ReportWithChart");
When the report is exported, the above code sees to it that the chart gets exported to the D:/inetpub/wwwroot/EspressReport/chartimages/
directory, with the charts being named ReportWithChart_0
, ReportWithChart_1
and ReportWithChart_2
(the extension depends on the image type set). And in the HTML/DHTML report, the following lines of code will be present:
<img src = "http://<machine name>/EspressReport/chartimages/ReportWithChart_0"> <img src = "http://<machine name>/EspressReport/chartimages/ReportWithChart_1"> <img src = "http://<machine name>/EspressReport/chartimages/ReportWithChart_2">
in place of the charts in the report.
To see an example of a servlet saving the report that contains charts as either a HTML or DHTML file on the server side, please go to EspressReport/help/examples/servlet/ReportWithChart
.
You can also add charts that contain hyperlinks to the report. When you export these types of reports to a DHTML or HTML file, the map file is automatically generated within the DHTML/HTML file as long as the option for the map file is selected in the Designer, or by setting the option in the Report API. The option is set by getting a handle to the ReportChartObject
and then using the method setExportMapFile
.
ReportChartObject reportChartObject = .......; reportChartObject.setExportMapFile(true);
Servlets and JSPs can send reports directly to the browser so that they do not need to be saved as files on the server side. Thus, disk space on the server is not being filled up and maintenance of files need not be done. However, a permanent copy of the report cannot be made (unless printed from the browser). Therefore, the report would need to be reprinted if it is needed again..
Sending reports to the browser differs from saving them to files, as here reports are sent as an outputstream
.
For a static format, on the servlet side, an outputstream
is created and the report is exported to the outputstream
.
public class OutputStreamServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // first, set the "content type" header of the response response.setContentType("text/html"); // where response is the response to the servlet OutputStream toClient = res.getOutputStream(); QbReport report = new QbReport (...........); .... .... .... report.export(QbReport.HTML, toClient); } }
In the browser, the servlet URL can be used to view the streamed HTML page. For example, you can enter the URL http://machine_name:8080/servlet/OutputStreamServlet
to generate the report and stream it to the browser as an HTML page.
For an interactive report, the report is exported as a string.
QbReport report = new QbReport (...........);
String buffer = report.exportReportToString();
....
....
....
On the HTML side, you can use Report Viewer to view the interactive report. Here, the HTML is embedded in the servlet code itself as shown :
toClient.println("<applet code=\"quadbase.reportdesigner.ReportViewer.Viewer\" width=600 height=600 " + "archive=\"http://<machineName>/EspressReport/lib/ReportViewer.jar\">"); toClient.println("<PARAM name=\"ReportData\" value=\"" + report.exportReportToString() +"\">"); toClient.println("</applet>");
To see an example of a servlet streaming the report as a HTML or DHTML file, please go to EspressReport/help/examples/servlet/StreamingReport
.
On a JSP, you have to create a Java Bean object (myStreamReport
), which creates a report and returns it as a String object. The JSP page has to be modified as shown :
<jsp:useBean id="myStreamReport" scope="page" class="streamingReport.CreateReport" /> <jsp:setProperty name="myStreamReport" property="*"/> <applet code="quadbase.reportdesigner.ReportViewer.Viewer" width=600 height=600 archive="http://<machineName>/EspressReport/lib/ReportViewer.jar"> <PARAM name="ReportData" value="<%= myStreamReport.export()%>"> </applet>
where myStreamReport
Java bean will contain the following code :
public string export() throws Exception { QbReport report = new QbReport(....); return report.exportReportToString(); }
To see an example of a JSP streaming the report as a HTML file, please go to EspressReport/help/examples/jsp/StreamingHTML
.
When you stream reports (in HTML or DHTML format) containing charts, you can either use the method setHTMLParameters
which saves the charts to a physical location on the server side, or you can stream the charts using the RPTImageGenerator
servlet provided. To use this servlet, you must make it accessible from your servlet runner or application server. The URL to access this servlet MUST be http://<machine name>:<port number>/servlet/RPTImageGenerator
. The source code for this servlet is in the EspressReport/ImageGenerator
directory. Next, in your servlet/jsp code, you must use the QbReport.setDynamicExport(boolean state, String serverName, int servletRunnerPort)
.
For example, given a report with three charts in it and the following method call:
report.setDynamicExport(true, "Aphrodite", 8080);
When the report is exported, the above code sees to it that the chart gets streamed using the machine Aphrodite and the port 8080. The RPTImageGenerator
servlet gets called using the URL, http://Aphrodite:8080/servlet/RPTImageGenerator
and thus streams the chart back to the browser.
You can also change the URL for this servlet by using the setServletDirectory(String)
method in the QbReport
class. For instance, given the example above, if the following line of code were added:
report.setServletDirectory("EspressReport/Test/");
then the links will show http://Aphrodite:8080/EspressReport/Test/RPTImageGenerator
instead of the default servlet/
in the link.
Further, if you are using SSL or wants to use a relative link to locate the RPTImageGenerator
, you can use the following methods to configure the SRC attribute of the IMG tag that is used to locate the RPTImageGenerator
:
/** use a relative URL for the SRC tag. */ report.setDynamicExport(boolean state, boolean relativeURLToImageGenerator); /** use https protocol along with specified server name and port number for the SRC tag. */ public void setHttpsDynamicExport(boolean state, String serverName, int servletRunnerPort);
To see an example of a servlet streaming the report, which contains charts, as a HTML or DHTML file, please go to EspressReport/help/examples/servlet/StreamingReportWithChart
.
You can also add in charts, that contain hyperlinks, to the report. When you export these types of reports to a DHTML or HTML file, the map file is automatically generated within the DHTML/HTML file as long as the option for the map file is selected in the Designer, or by setting the option in the Report API. The option is set by getting a handle to the ReportChartObject
and then using the method setExportMapFile
.
ReportChartObject reportChartObject = .......; reportChartObject.setExportMapFile(true);