Deploying a Servlet in JRun

In this document we walk you through all the steps you must take to deploy the sample Servlet into JRun 3.1 Application Server.

The steps involved

  1. Preparation

  2. Sharing Library files

  3. Resolving Security

  4. Deploy the example

  5. Run the example
  6. Setting Up the Environment

Preparation

  1. 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®.

  2. Include jintegra.jar, and excel.jar into your CLASSPATH environment variable.

  3. Go to the local directory in which you copied ExcelCalculatorExample.java, and enter the following command to compile it:
    javac ExcelCalculatorExample.java

Sharing Library Files

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.

  1. Start the JRun Management Console and enter the password to log in.

  2. Click JRun Default Server and select Java Settings in the left panel.

  3.  Click Classpath.

  4. 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:

  5. 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.

Resolving Security

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.

  1. Start the JRun Management Console and enter the password to log in.

  2. Click JRun Default Server and select Java Settings in the left panel.

  3. Click Library Path.

  4. 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:

  5. Click update. Then, to be safe, restart your JRun Default Server.

Deploy the example

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.

  1. Ensure that you have you have installed the J-Integra® license.

  2. 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:

  3. 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>

  4. Create a manifest file: Create a file called Manifest.mf (it can be an empty file). Save this file in the META-INF directory.

  5. Copy ExcelCalculatorExample.class to WEB-INF/classes.

  6. Copy ExcelCalculator.html to Deploy.

  7. After you finished placing these files on the correct place, your directory structure looks like this:

  8. Now create a WAR file. In the Deploy directory, enter this command:
    jar cvf ExcelExample.war *.*

  9. 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.

  10. Click JRun Default Server. Then click Web Applications.

  11. In the right panel, click Deploy an Application.

  12. 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.

  13. Click deploy.

Run the example

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.

  • Setting Up the Environment

    For information on setting up the environment for different platforms, see Setting up the environment to run a JSP and/or Servlet file.