Chapter 11. Servlets and JavaServer Pages

11.1. Servlets

11.1.1. Introduction

As described on the Oracle Web site (http://www.oracle.com), "Java Servlet technology provides 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 make many web applications possible. Today, servlets are a popular choice for building interactive web applications. Servlet containers are available for Apache Web 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 the example servlet provided with EspressChart (located in EspressChart/help/examples/servlet/DatabaseJPEG). Please note that each section deals specifically with the example database servlet. They can however be used as a guide for setting up and running your own servlets as well as the other example servlets given.

In addition to the database servlet, other servlet examples have also been provided. They range from the simple showing of a chart (either as an applet or as a static image) to the streaming of the chart directly to the browser to showing drill-down charts as a static image. Setup and running of these examples can be done using the following sections as a guide.

11.1.2. Setup

  1. Make sure that the EspressManager is running

  2. Next, depending on what servlet server (runner) that you are using, follow the guideline below. Then run ExportChart2.html (located in the EspressChart/help/examples/servlet/DataFile directory) from a browser.

[Note]Note

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-thread model for simplicity's sake. However, EspressChart API can also be used in a multi-thread environment.

The following uses the DataFile servlet example under EspressChart/help/examples/servlet.

11.1.3. Running Under

11.1.3.1. Apache Tomcat

Checking Tomcat version

Please be sure you have Tomcat server 5.5.20 or 6.0.10 installed. (This guide may also be applicable for previous versions.)

There are two installation file versions for Windows operating system:

zip file

uses startup.bat and shutdown.bat files for starting and stopping the server, that can be found after extraction of the archive in bin directory

exe file

installs Windows service and uses Apache Tomcat Monitor application

EspressManager should be running

Please, run EspressManager by executing EspressManager.bat in <EspressChart install dir>.

Virtual directory mapping

In order to make example work correctly, you need to map EspressChart install directory as a virtual directory under Apache Tomcat's webroot.

Please open server.xmlfile (placed in <Tomcat install dir>\conf\ directory) with an editor and add the following:

<Context path="/EspressChart" docBase="<EspressChart install dir path>" debug="0" privileged="true"/>

between <Host> and </Host> xml tags and save the changes.

For example:

<Context path="/EspressChart" docBase="c:\EspressChart" debug="0" privileged="true"/> 
[Note]Note

You can also install EspressChart to <Tomcat install dir>\webapps\ROOT directory to avoid virtual directory mapping. However, this is not recommended.

Classpath setting

You should include EspressAPI.jar and servlet-api.jarfiles in the classpath.

EspressAPI.jar file can be found in EspressChart\lib directory, servlet-api.jar in <Tomcat install dir>\common\lib\ directory

Here is the example classpath setting (using command line console):

set classpath=%classpath%;<Tomcat 5.5 install dir>\common\lib\servlet-api.jar; C:\EspressChart\lib\EspressAPI.jar (when using Tomcat 5.5 server version)

set classpath=%classpath%;<Tomcat 6.0 install dir>\lib\servlet-api.jar; C:\EspressChart\lib\EspressAPI.jar (when using Tomcat 6.0 server version) 
[Note]Note

Classpath does not necessarily need to be set, but it simplifies .javafiles compilation (you do not need to add classpath there).

[Tip]Tip

You can set Classpath variable also using MyComputer -> Administrate -> Details tab window.

Compiling the example file (ExportServlet2.java)

Compile command:

(if classpath environment variable was not set in step 4 of this guide)

javac -classpath "<Tomcat 5.5 install dir>\common\lib\servlet-api.jar; C:\EspressChart\lib\EspressAPI.jar" ExportServlet2.java (for Tomcat 5.5 server version)

javac -classpath "<Tomcat 6.0 install dir>\lib\servlet-api.jar; C:\EspressChart\lib\EspressAPI.jar" ExportServlet2.java (for Tomcat 6.0 server version) 

or simply:

(if classpath was set properly)

javac ExportServlet2.java 
Copying the class file to Tomcat’s deploying directory

Please copy ExportServlet2.class file to <Tomcat install dir>\webapps\ROOT\WEB-INF\classes directory.

[Note]Note

Please note that <Tomcat install dir>\webapps\ROOT\WEB-INF\classes directory does not need to exist by default and you will have to create it.

Adding necessary libraries for running the servlet to lib dir

In order to run the example, you also need to add necessary libraries to your web application's lib directory. Please copy EspressAPI.jar file placed in EspressChart\lib directory to <Tomcat install dir>\webapps\ROOT\WEB-INF\lib directory.

[Note]Note

Please note that <Tomcat install dir>\webapps\ROOT\WEB-INF\lib directory does not need to exist by default and you will have to create it.

Registering your servlet appplication in web.xml file

Before you can run your servlet application you need to modify your application's web.xml file. It is placed in <Tomcat install dir>\webapps\ROOT\WEB-INF\ directory.

For registering ExportServlet2, please add the following code:

<servlet>
	        <servlet-name>ExportServlet2</servlet-name>
	        <servlet-class>ExportServlet2</servlet-class>
	    </servlet>

	    <servlet-mapping>
	        <servlet-name>ExportServlet2</servlet-name>
	        <url-pattern>/servlet/ExportServlet2</url-pattern>
	    </servlet-mapping>

between <web-app> and </web-app> xml tags.

[Note]Note

You can also enable automatic invoking of all servlets that are placed in webapp directory. Then you do not need to register your servlet applications. This is intended only for test purposes. Using the invoker servlet in a production environment is not recommended and is unsupported. For more information, consult documentation of your Tomcat server.

Starting Tomcat server

If you used zip installation file, please run startup.bat (startup.sh for Linux) file (placed in <Tomcat install dir>\bin directory).

For exe installation files you need to startup the Tomcat service. You can use Tomcat’s “Monitor Tomcat” application for this purpose.

[Note]Note

If your Tomcat server is already running, you probably need to restart it (shutdown and start again) in order to run the example.

Running the example

The last step is running the example. To run the example, simply run ExportChart2.html file (placed in EspressChart\help\examples\servlet\DataFile directory) in your browser. You can set the path to your data file or you can use the default one that comes with EspressChart installation. By clicking on Get Chart Image button, the ExportServlet2 is called and the chart image is exported and then printed on the page.

[Note]Note

Please be sure that EspressManager is running before you run the example.

[Note]Note

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 ExportChart2.html file

From:

<form action="http://localhost:8080/servlet/ExportServlet2" method="post">

To:

<form action="http://<machine_name>:8080/servlet/ExportServlet2" method="post"> 

11.1.3.2. JRun

  • Replace the machine name and port number in the html file to

    <FORM ACTION=http://<machine name>:8100/servlet/ExportServlet method=POST>

    where <machine name> is the name of the machine running the JRun server.

  • Log into the JRun Default Server Administrator

  • Click on Java Settings and then Classpath

  • Add the path to EspressAPI.jar and ExportLib.jar in separate lines and click on Update

  • Restart the JRun Default Server

  • Compile the servlet and copy it to <jrun_installation_directory>/servers/default/default-app/WEB-INF/classes

  • Open up modified ExportChart2.html in a browser, input the parameters, and then click on button to get the chart.

11.1.3.3. ColdFusion Server

  • Rename ExportChart2.html to ExportChart2.cfm and replace the machine name and port number in the cfm file to

    <FORM ACTION=http://<machine name>:8100/servlet/ExportServlet method=POST>

    where, <machine name> is the name of the machine running the JRun server.

  • Log into the JRun Default Server Administrator

  • Click on Java Settings and then Classpath

  • Add the path to EspressAPI.jar and ExportLib.jar in separate lines and click on Update

  • Restart the JRun Default Server

  • Compile the servlet and copy it to <jrun_installation_directory>/servers/default/default-app/WEB-INF/classes

  • Open up the modified ExportChart2.cfm in a browser, input the parameters, and click on the button to get chart.

11.1.3.4. WebLogic 6.0

For the NT platform, to run EspressChart under WebLogic 6.0, install it under the bea\wlserver6.0\config\examples\applications\examplesWebApp directory. To access it, type in http://<web address or machine name>:7001/examplesWebApp/ EspressChart/index.html. Remember to start EspressManager first as you will be accessing the Chart Designer.

To set up and run the servlet example, first, you must go to the wlserver6.0\config\examples directory. Modify both setExamplesEnv.cmd and startExamplesServer.cmd files according to the following instructions:

  • Add set ES_CHART=YOUR_WEBROOT\espresschart in the @rem Set user-defined variables section. If you installed WebLogic 6.0 under c:\bea, YOUR_WEBROOT is equal to c:\bea\wlserver6.0\config\examples\applications. The ES_CHART variable contains the path to the EspressChart 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 c:\bea;.; %ES_CHART%\lib\EspressAPI.jar; %ES_CHART%\lib\ExportLib.jar; to the set CLASSPATH field of the same file.

Next, follow the steps below (note that the files are under espresschart\help\examples\servlet\Weblogic directory):

  • Put the ExportChart2.html in the wlserver6.0\config\examples\applications\examplesWebApp directory.

  • Change the machine name in the code archon:7001 to yourMachineName:7001 in the ExportChart2.html file.

  • Put the ExportServlet2.java file 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, under the examplesWebApp 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>ExportServlet2</servlet-name>
            <servlet-class>ExportServlet2</servlet-class>
    
                <init-param>
    
                    <param-name>dataFileName</param-name>
                    <param-value>help/examples/data/sample.dat</param-value>
    
                </init-param>
                <init-param>
    
                    <param-name>category</param-name>
                    <param-value>0</param-value>
    
                </init-param>
                <init-param>
    
                    <param-name>series</param-name>
                    <param-value>-1</param-value>
    
                </init-param>
                <init-param>
    
                    <param-name>sumby</param-name>
                    <param-value>-1</param-value>
    
                </init-param>
                <init-param>
    
                    <param-name>value</param-name>
                    <param-value>3</param-value>
    
                </init-param>
                <init-param>
    
                    <param-name>chartType</param-name>
                    <param-value>Column</param-value>
    
                </init-param>
                <init-param>
    
                    <param-name>fileName</param-name>
                    <param-value>c:\temp</param-value>
    
                </init-param>
    
            </servlet>
    
        <servlet-mapping>
    
            <servlet-name>ExportServlet2</servlet-name>
            <url-pattern>/ExportServlet2/*</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 ExportServlet2.java using the command lines listed below.

    javac –d %EX_WEBAPP_CLASSES% ExportServlet2.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/ExportChart2.html to view the servlet example.

[Tip]Tip

For troubleshooting please check for typing errors.

11.1.3.4.1. WebLogic 9.2

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 EspressChart installation will be referenced as <EC_INSTALL_DIR>.

In order to run EspressChart under WebLogic 9.2, install it under the <WL_INSTALL_DIR>\samples\server\examples\build\examplesWebApp directory. To access it, type in http://<web address or machine name>:7001/examplesWebApp/EspressChart/index.html. Remember to start EspressManager first as you will be accessing the Chart Designer.

To set up and run the servlet example, first, you must 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_CHART=<EC_INSTALL_DIR>. If you installed WebLogic 9.2 under c:\bea, <EC_INSTALL_DIR> , it is equal to C:\bea\weblogic92\samples\server\examples\build\examplesWebApp\EspressChart. The ES_CHART variable contains the path to the EspressChart 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_CHART%\lib\EspressAPI.jar; %ES_CHART%\lib\ExportLib.jar; %ES_CHART%\lib\qblicense.jar; to the set CLASSPATH field of the same file.

Next, follow the steps below (note that the files are under <EC_INSTALL_DIR>\help\examples\servlet\Weblogic directory):

  • Put the DialServletDemo.java & DialServletExp.java files in the <WL_INSTALL_DIR>\samples\server\examples\build\examplesWebApp\WEB-INF\classes directory.

  • Change the machine name in the code fragment archon:7001 to yourMachineName:7001 in the DialServletDemo.java file.

  • Change the constructor bellow in the DialServletExp.java file.

    From:

    chart = new QbChart(new Frame(), QbChart.VIEW2D, QbChart.DIAL, data, colInfo, "config/examples/applications/examplesWebApp/WEB-INF/classes/dial.tpl"); 

    To:

    chart = new QbChart(new Frame(), QbChart.VIEW2D, QbChart.DIAL, data, colInfo, "samples/server/examples/examplesWebApp/WEB-INF/classes/dial.tpl");. 
  • 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>DialServletExp</servlet-name>
            <servlet-class>DialServletExp</servlet-class> 
    
        </servlet>
    
        <servlet>
    
            <servlet-name>DialServletDemo</servlet-name>
            <servlet-class>DialServletDemo</servlet-class> 
    
        </servlet>
    
        <servlet-mapping>
    
            <servlet-name>DialServletExp</servlet-name>
            <url-pattern>/DialServletExp/*</url-pattern> 
    
        </servlet-mapping>
    
        <servlet-mapping>
    
            <servlet-name>DialServletDemo</servlet-name>
            <url-pattern>/DialServletDemo/*</url-pattern> 
    
        </servlet-mapping> 
  • Copy the DialServletDemo.html file to the <WL_INSTALL_DIR>\samples\server\examples\build\examplesWebApp directory.

  • Edit the DialServletDemo.html file and change all machine names from archon:7001/servlet to yourMachineName:7001/examplesWebApp.

  • Copy the dial.tpl file to the <WL_INSTALL_DIR>\samples\server\examples\build\examplesWebApp\WEB-INF\classes directory.

  • Then, go to <WL_INSTALL_DIR>\samples\server\examples\build\examplesWebApp\WEB-INF\classes directory and compile DialServletExp.java & DialServletDemo.java. Please include EspressAPI.jar, ExportLib.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/DialServletDemo.html to view the servlet example.

[Tip]Tip

For troubleshooting, please check for typing errors.

11.1.3.5. WebSphere 3.5

  • Open the WebSphere Administrator's Console and under the node (usually the machine name) <MACHINE_NAME>Default Servlet EngineDefault App, click on the Advanced tab and add EspressAPI.jar and ExportLib.jar(in separate lines) to the Classpath. Then click on Apply

  • Move the compiled class file (ExportServlet2.class) to the <WebSphere installation directory>/AppServer/servlets directory

  • Modify the FORM ACTION tag to the following:

    <FORM ACTION=http://<machine name>/servlet/ExportServlet2 method=POST>
  • Start/Restart the Default Server under the node

11.1.3.5.1. WebSphere 6.1

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 WebLogic installation will be referenced as <WS_INSTALL_DIR> and the location of the EspressChart installation will be referenced as <EC_INSTALL_DIR>.

To set up and run the servlet example, first, copy <EC_INSTALL_DIR>\lib\EspressAPI.jar, <EC_INSTALL_DIR>\lib\ExportLib.jar and <EC_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 <EC_INSTALL_DIR>\help\examples\servlet\DataFile directory):

  • Put the ExportServlet2.java file in the <WS_INSTALL_DIR>\AppServer\profiles\AppSrv01\installedApps\<YourMachineName>Node01Cell\ivtApp.ear\ivt_app.war\WEB-INF\classes directory.

  • Insert the following code fragments in the web.xml file located in the <WS_INSTALL_DIR>\AppServer\profiles\AppSrv01\installedApps\<YourMachineNam>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>ExportServlet2</servlet-name>
            <servlet-class>ExportServlet2</servlet-class> 
    
        </servlet>
    
        <servlet-mapping>
    
            <servlet-name>ExportServlet2</servlet-name>
            <url-pattern>ExportServlet2</url-pattern> 
    
        </servlet-mapping> 
  • Edit the ExportChart2.html file and change the machine name and port from yourmachine:8080 to yourMachineName:9080/ivt.

  • Copy the ExportChart2.html file to the <WS_INSTALL_DIR>\AppServer\profiles\AppSrv01\installedApps\<YourMachineName>Node01Cell\ivtApp.ear\ivt_app.war directory.

  • Edit the ExportServlet2.java file and change code fragment from http://yourmachine:8080/EspressChart/ to <EC_INSTALL_DIR>.

  • Then, go to <WS_INSTALL_DIR>\AppServer\profiles\AppSrv01\installedApps\<YourMachineName>Node01Cell\DefaultApplication.ear\DefaultWebApplication.war\WEB-INF\classes directory and compile ExportServlet2.java. Please include EspressAPI.jar, ExportLib.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 StartProgramsIBM WebSphereApplication Server v6.1ProfilesAppSrv01First Steps. You can also launch the administration console from the First Steps tool.

  • Open your web browser and go to http://yourMachineName:9080/ivt/ExportChart2.html to view the servlet example.

[Tip]Tip

For troubleshooting, please check for typing errors.

11.1.3.6. JBoss 4.0.5

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 EspressChart installation will be referenced as <EC_INSTALL_DIR>.

To set up and run the servlet example, first, go to the <JB_INSTALL_DIR>JB_INSTALL_DIR>\bin directory. Next,modify the run.bat file according to the following instructions:

  • Add set ES_CHART=<EC_INSTALL_DIR>. The ES_CHART variable contains the path to the EspressChart home directory in your machine.

  • Add %ES_CHART%\lib\EspressAPI.jar; %ES_CHART%\lib\ExportLib.jar; %ES_CHART%\lib\qblicense.jar; to the set JBOSS_CLASSPATH field of the same file. Do not type in the double quote.

Next, follow the steps below (note that the files are under <EC_INSTALL_DIR>\help\examples\servlet\DataFile directory):

  • Put the ExportServlet2.java file in the <JB_INSTALL_DIR>\server\default\deploy\jmx-console.war\WEB-INF\classes directory.

  • Edit the ExportServlet2.java file and change code fragment from http://yourmachine:8080/EspressChart/ to <EC_INSTALL_DIR>.

  • 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>ExportServlet2</servlet-name>
            <servlet-class>ExportServlet2</servlet-class> 
    
        </servlet>
    
        <servlet-mapping>
    
            <servlet-name>ExportServlet2</servlet-name>
            <url-pattern>/ExportServlet2</url-pattern> 
    
        </servlet-mapping> 
  • Edit the ExportChart2.html file and change part of URL http://yourmachine:8080/servletto http://yourMachineName:8080/jmx-console.

  • Copy the ExportChart2.html file to the <JB_INSTALL_DIR>\server\default\deploy\jmx-console.war directory.

  • Then, go to <JB_INSTALL_DIR>\server\default\deploy\jmx-console.war\WEB-INF\classes directory and compile ExportServlet2.java. Please include EspressAPI.jar, ExportLib.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/ExportChart2.html to view the servlet example.

[Tip]Tip

For troubleshooting, please check for typing errors.

11.1.3.7. Orion 2.0.7

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 EspressChart installation will be referenced as <EC_INSTALL_DIR>.

Follow the steps below (note that the files are under <EC_INSTALL_DIR>\help\examples\servlet\DataFile directory):

  • Put the ExportServlet2.java file in the <OR_INSTALL_DIR>\default-web-app\WEB-INF\classes directory.

  • Edit the ExportServlet2.java file and change code fragment from http://yourmachine:8080/EspressChart/ to <EC_INSTALL_DIR>.

  • 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>ExportServlet2</servlet-name>
            <servlet-class>ExportServlet2</servlet-class> 
    
        </servlet>
    
        <servlet-mapping>
    
            <servlet-name>ExportServlet2</servlet-name>
            <url-pattern>ExportServlet2</url-pattern> 
    
        </servlet-mapping> 
  • Edit the ExportChart2.html file and change part of URL http://yourmachine:8080/servlet to http://yourMachineName:80.

  • Copy the ExportChart2.html file to the <OR_INSTALL_DIR>\default-web-app directory.

  • Then, go to <OR_INSTALL_DIR>default-web-app\WEB-INF\classes directory and compile ExportServlet2.java. Please include EspressAPI.jar, ExportLib.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).

  • 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/ExportChart2.html” to view the servlet example.

[Tip]Tip

For troubleshooting, please check for typing errors.

11.1.3.8. JRun 4 (with Update 6)

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 EspressChart installation will be referenced as <EC_INSTALL_DIR>.

Follow the steps below (note that the files are under <EC_INSTALL_DIR>\help\examples\servlet\DataFile directory):

  • Put the ExportServlet2.java file in the <JR_INSTALL_DIR>\servers\default\default-ear\default-war\WEB-INF\classes directory.

  • Edit the ExportServlet2.java file and change code fragment from http://yourmachine:8080/EspressChart/ to <EC_INSTALL_DIR>.

  • 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>ExportServlet2</servlet-name>
            <servlet-class>ExportServlet2</servlet-class> 
    
        </servlet>
    
        <servlet-mapping>
    
            <servlet-name>ExportServlet2</servlet-name>
            <url-pattern>ExportServlet2</url-pattern> 
    
        </servlet-mapping> 
  • Edit the ExportChart2.html file and change part of URL http://yourmachine:8080/servlet to http://yourMachineName:8100.

  • Copy the ExportChart2.html file to the <JR_INSTALL_DIR>\servers\default\default-ear\default-war directory.

  • Then, go to <JR_INSTALL_DIR>\servers\default\default-ear\default-war\WEB-INF\classes directory and compile ExportServlet2.java. Please include EspressAPI.jar, ExportLib.jar and j2ee.jar in the classpath.

    [Tip]Tip

    You can use j2ee.jar from the J2eeSDK installation located under <J2EE_SDK_INSTALL_DIR>\lib directory

  • Copy the EspressAPI.jar, ExportLib.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/ExportChart2.html to view the servlet example.

[Tip]Tip

For troubleshooting, please check for typing errors.

11.1.3.9. Oracle 10g (10.1.3.1.0)

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 EspressChart installation will be referenced as <EC_INSTALL_DIR>.

Follow the steps below (note that the files are under <EC_INSTALL_DIR>\help\examples\servlet\StreamingChart directory):

  • Put the StreamChartServlet.java file in the <ORA_INSTALL_DIR>\j2ee\home\default-web-app\WEB-INF\classes directory.

  • Edit the StreamChartServlet.java file and change code fragment from http://yourmachine:8080/EspressChart to <EC_INSTALL_DIR>.

  • 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>StreamChartServlet</servlet-name>
            <servlet-class>StreamChartServlet</servlet-class> 
    
        </servlet>
    
        <servlet-mapping>
    
            <servlet-name>StreamChartServlet</servlet-name>
            <url-pattern>/servlet/StreamChartServlet</url-pattern> 
    
        </servlet-mapping>
  • Edit the StreamChartServlet.html file and change part of URL http://yourmachine:8080/servlet to http://yourMachineName:8888/servlet.

  • Copy the StreamChartServlet.html file to the <ORA_INSTALL_DIR>\j2ee\home\default-web-app directory.

  • Then, go to <ORA_INSTALL_DIR>\j2ee\home\default-web-app\WEB-INF\classes directory and compile StreamChartServlet.java. Please include EspressAPI.jar, ExportLib.jar and servlet.jar in the classpath.

    [Tip]Tip

    The servlet.jar file is located under <ORA_INSTALL_DIR>\j2ee\home\lib directory

  • Copy the EspressAPI.jar, ExportLib.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 StartProgramsOracleStart Soa suite. 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/StreamChartServlet.html to view the servlet example.

[Tip]Tip

For troubleshooting, please check for typing errors.

11.1.3.10. Sun Java System Application PE (9.0, 8.2)

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 EspressChart installation will be referenced as <EC_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.

    [Tip]Tip

    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 <EC_INSTALL_DIR>\help\examples\servlet\DataFile directory):

  • Put the ExportServlet2.java file in the <USER_DIR>\WEB-INF\classes directory.

  • Edit the ExportServlet2.java file and change code fragment from http://yourmachine:8080/EspressChart/ to <EC_INSTALL_DIR>.

  • Insert the following code fragments in the web.xmlfile located in the <USER_DIR>\WEB-INF directory.

        <servlet>
    
            <servlet-name>ExportServlet2</servlet-name>
            <servlet-class>ExportServlet2</servlet-class> 
    
        </servlet>
    
        <servlet-mapping>
    
            <servlet-name>ExportServlet2</servlet-name>
            <url-pattern>/servlet/ExportServlet2</url-pattern> 
    
        </servlet-mapping>
  • Edit the ExportChart2.html file and change the part of URL http://yourmachine:8080/servletto http://yourMachineName:8080/hello/servlet.

  • Copy the ExportChart2.html file to the <USER_DIR> directory.

  • Then, go to <USER_DIR>\WEB-INF\classes directory and compile ExportServlet2.java. Please include EspressAPI.jar, ExportLib.jar and j2ee.jar in the classpath.

    [Tip]Tip

    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 EspressAPI.jar, ExportLib.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 StartProgramsSun MicrosystemsApplication Server PE 9Start Default Server.

  • Open your web browser and go to http://yourMachineName:8080/hello/ExportChart2.htmlto view the servlet example.

[Tip]Tip

For troubleshooting please check for typing errors.

11.1.3.11. Sun Java System WebServer 7.0

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 EspressChart installation will be referenced as <EC_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.

    [Tip]Tip

    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 webapps-simple.war in the <USER_DIR> directory.

Follow the steps below (note that the files are under <EC_INSTALL_DIR>\help\examples\servlet\DataFile directory):

  • Put the ExportServlet2.java file in the <USER_DIR>\WEB-INF\classes directory.

  • Edit the ExportServlet2.java file and change code fragment from http://yourmachine:8080/EspressChart/ to <EC_INSTALL_DIR>.

  • 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>ExportServlet2</servlet-name>
            <servlet-class>ExportServlet2</servlet-class> 
    
        </servlet>
    
        <servlet-mapping>
    
            <servlet-name>ExportServlet2</servlet-name>
            <url-pattern>/servlet/ExportServlet2</url-pattern> 
    
        </servlet-mapping>
  • Edit the ExportChart2.html file and change the part of URL http://yourmachine:8080/servlet to http://yourMachineName:81/webapps-simple/servlet.

  • Copy the ExportChart2.html file to the <USER_DIR> directory.

  • Then, go to <USER_DIR>\WEB-INF\classes directory and compile ExportServlet2.java. Please include EspressAPI.jar, ExportLib.jar and j2ee.jar in the classpath.

    [Tip]Tip

    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 then create a war file by executing the following command: jar -cvf webapps-simple.war *.

  • Copy the EspressAPI.jar, ExportLib.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 Browse button and navigate to 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 OK button.

  • From the next screen you should see the webapps-simple application enabled. Next click the Save button. After that you will see the Deployment Pending warning link in the upper right corner of the screen. Click the link and push the Deploy button.

  • If 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/ExportChart2.html to view the servlet example.

[Tip]Tip

For troubleshooting please check for typing errors.

11.1.3.12. Resing 3.1.0

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 EspressChart installation will be referenced as <EC_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.

    [Tip]Tip

    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 resin-doc.war in the <USER_DIR> directory.

  • 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):

  • Put the ExportServlet2.java file in the <RES_INSTALL_DIR>\webapps\test\WEB-INF\classes directory.

  • Edit the ExportServlet2.java file and change code fragment from http://yourmachine:8080/EspressChart/to <EC_INSTALL_DIR>.

  • Insert the following code fragments in the resin-web.xmlfile located in the <RES_INSTALL_DIR>\webapps\test\WEB-INF directory.

    <servlet-name="ExportServlet2" servlet-class="ExportServlet2"/>
    
    <servlet-mapping url-pattern="/servlet/ExportServlet2" servlet-name="ExportServlet2"/>
  • Edit the ExportChart2.html file and change the part of URL http://yourmachine:8080/servlet to http://yourMachineName:8080/test/servlet.

  • Copy the ExportChart2.html file to the <RES_INSTALL_DIR>\webapps\test directory.

  • Then, go to <RES_INSTALL_DIR>\webapps\test\WEB-INF\classes directory and compile ExportServlet2.java. Please include EspressAPI.jar, ExportLib.jar and j2ee.jar in the classpath.

    [Tip]Tip

    You can use j2ee.jar from the J2eeSDK installation located under <J2EE_SDK_INSTALL_DIR>\lib directory).

  • Copy the EspressAPI.jar, ExportLib.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/ExportChart2.html to view the servlet example.

[Tip]Tip

For troubleshooting, please check for typing errors.

11.1.3.13. ColdFusion MX 7.02

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 installation will be referenced as <CF_INSTALL_DIR> and the location of the EspressChart installation will be referenced as <EC_INSTALL_DIR>.

Follow the steps below (note that the files are under <EC_INSTALL_DIR\help\examples\servlet\DataFile directory):

  • Put the ExportServlet2.java file in the <CF_INSTALL_DIR>\wwwroot\WEB-INF\classes directory.

  • Edit the ExportServlet2.java file and change code fragment from http://yourmachine:8080/EspressChart/ to <EC_INSTALL_DIR>.

  • 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>ExportServlet2</servlet-name>
            <servlet-class>ExportServlet2</servlet-class> 
    
        </servlet>
    
        <servlet-mapping>
    
            <servlet-name>ExportServlet2</servlet-name>
            <url-pattern>/servlet/ExportServlet2</url-pattern> 
    
        </servlet-mapping>
  • Edit the ExportChart2.html file and change the part of URL http://yourmachine:8080 to http://yourMachineName:8500.

  • Copy the ExportChart2.html file to the <CF_INSTALL_DIR>\wwwroot directory.

  • Then, go to <CF_INSTALL_DIR>\wwwroot\WEB-INF\classes directory and compile ExportServlet2.java. Please include EspressAPI.jar, ExportLib.jar and j2ee.jar in the classpath

    [Tip]Tip

    You can use j2ee.jar from the J2eeSDK installation located under <J2EE_SDK_INSTALL_DIR>\lib directory).

  • Copy the EspressAPI.jar, ExportLib.jar and qblicense.jar files to the <CF_INSTALL_DIR>\runtime\lib directory.

  • Start the ColdFusion application server. For Windows platforms, the ColdFusion application server is installed to run as a service; therefore, 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/ExportChart2.html to view the servlet example.

[Tip]Tip

For troubleshooting, please check for typing errors.

11.1.4. Running the Servlet

After setting up the servlet per the instructions given above, open ExportChart2.html (located in the EspressChart/help/examples/servlet/DataFile directory) from a browser. Select from the parameters given and then click on Get Chart Image.

[Note]Note

You may have to clear the memory cache and disk cache every time in order get the latest result.