In this document we walk you through all the steps you must take to deploy the sample Servlet into JRun 3.1 Application Server.
Copy the provided ExcelCalculator.html, and ExcelCalculatorExample.java files into a local directory that will be the target directory of your deployment. These files are included in your jintegra\examples\servlet-com\ServletToExcelCalculator directory when you download J-Integra®.
Include jintegra.jar, and excel.jar into your CLASSPATH environment variable.
Go to the local directory in which you copied
ExcelCalculatorExample.java, and enter the following command to compile it:
javac ExcelCalculatorExample.java
The application server needs to know where it can find the classes referred to by the Servlet. If you want to share these jar files among other servlets and JSPs, JRun allows you to specify the path to the java library files that they use. In this section you will learn the steps to setup the path to the library files.
Start the JRun Management Console and enter the password to log in.
Click JRun Default Server and select Java Settings in the left panel.
Click Classpath.
Add the path to your jar files in the Input Field. For example, if your jintegra.jar is in D:\Jlib, and your excel.jar is in D:\Jlib, your final result will look like this:
After you finished adding these jar files to the classpath, you no longer need them in your WAR file. Remember, you can open up a WAR file using winzip.exe and then delete the jar files and lib directory. Or you can use the jar command to do that. Or you can create a new WAR file without adding the jar files. After you have updated the new WAR file, deploy it in JRun again and restart the JRun Default Server.
In order to have access to a COM object, Windows needs authentication information. J-Integra® comes with a DLL that performs the authentication for you. This DLL is in the 'bin' directory of the J-Integra®. You must add this 'bin' directory to your PATH environment variable. If JRun is ignoring the path you have set on your computer, you have another option to inform the JRun of the path you want to add. In this section you learn how to set the path in JRun.
Start the JRun Management Console and enter the password to log in.
Click JRun Default Server and select Java Settings in the left panel.
Click Library Path.
Add the path to your native libraries under Input Fields. Remember that you must add a semi-colon first and then the path. For example, if your libraries are in D:\Test J-Integra®\jintegra\bin, your final result will look like this:
Click update. Then, to be safe, restart your JRun Default Server.
This section explains how you can run the ExcelCalculatorExample in JRun 3.1. The easiest way to deploy a servlet in JRun is by having a WAR file that contains all necessary files. You need ExcelCalculatorExample.class file, ExcelCalculator.html, and finally the XML descriptor.
Ensure that you have you have installed the J-Integra® license.
Create the deployment directory: Create a directory and call it Deploy. Create two directories beneath this directory and name them META-INF and WEB-INF (Note: names are case sensitive). Beneath WEB-INF, create a directory named classes. Now you should have a directory structure that looks like this:
Create the XML descriptor: Here is the sample XML descriptor you can use to deploy this sample. Save this file as web.xml in the WEB-INF directory.
This file is included in your jintegra\examples\servlet-com\ServletToExcelCalculator directory (named web.xml) when you download J-Integra®.
<?xml version="1.0" encoding="Cp1252"?> <!DOCTYPE web-app PUBLIC '-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN' 'http://java.sun.com/dtd/web-app_2_3.dtd'> <web-app> <display-name>ExcelServlet</display-name> <description>no description</description> <servlet> <servlet-name>ExcelCalculator</servlet-name> <display-name>ExcelCalculator</display-name> <description>no description</description> <servlet-class>ExcelCalculatorExample</servlet-class> </servlet> <servlet-mapping> <servlet-name>ExcelCalculator</servlet-name> <url-pattern>/ExcelCalculatorAlias</url-pattern> </servlet-mapping> <session-config> <session-timeout>30</session-timeout> </session-config> </web-app> |
Create a manifest file: Create a file called Manifest.mf (it can be an empty file). Save this file in the META-INF directory.
Copy ExcelCalculatorExample.class to WEB-INF/classes.
Copy ExcelCalculator.html to Deploy.
After you finished placing these files on the correct place, your directory structure looks like this:
Now create a WAR file. In the Deploy directory, enter this command:
jar cvf ExcelExample.war *.*
We have the WAR file and we can deploy it into the JRun Application Server. Start the JRun Management Console and enter the password to log in.
Click JRun Default Server. Then click Web Applications.
In the right panel, click Deploy an Application.
Click the Browse button and select the WAR file you created in step 8. Type in ExcelCalculator as the Application Name and /ExcelCalculator as the Application URL. Do not forget to put / at the beginning of the Application URL.
Click deploy.
If the deployment was successful, you need to restart the JRun server in order to use the newly deployed servlet. Double-click on the JRun Default Server icon on your system tray and click the Restart button.
Open your Web browser and enter http://localhost:8100/ExcelCalculator/ExcelCalculator.html as the URL.
Enter two numbers and click Submit.
For information on setting up the environment for different platforms, see Setting up the environment to run a JSP and/or Servlet file.