Deploying a Servlet to the J2EE Reference Implementation Server

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

The steps involved

  1. Preparation

  2. Deploy the example

  3. Run the example
  4. Setting Up the Environment

Preparation

  1. We want to share excel.jar and jintegra.jar. In order to share these two files you must add them to your J2EE_CLASSPATH environment variable. If your J2EE application server is running, you must stop it and set this environment variable first and then restart the J2EE application server.

  2. In order to have access to a COM object, Windows NT needs to authenticate you. J-Integra® can do this for you, if it can find a native DLL that performs the authentication. You must include the bin sub-directory under J-Integra® directory to your path environment variable. Again, if your J2EE server is running, stop it and set this environment variable properly and then restart the J2EE server.

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

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

Deploy the example

This section explains how you can run the ExcelCalculatorExample on the J2EE Reference Application Server provided by Sun Microsystems. The deployment tool used to deploy the servlet is Application Deployment Tool Version 1.3. The same procedure applies if you are using another version of this deployment tool.

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

  2. Open a DOS session and set the PATH, CLASSPATH, and J2EE_CLASSPATH environment variables and enter this command to start the J2EE server:
    j2ee –verbose

  3. Open another DOS session and set the PATH, CLASSPATH, and J2EE_CLASSPATH environment variables and enter this command to start the deployment tool:
    deploytool

  4. The Application Deployment Tool should open.

  5. In the File menu, click New, and then click Application.

  6. Select the directory that you want to put the files that are generated by the deploytool. Name the new application ExcelCalculatorExample.ear. Do not forget the .ear extension.

  7. ExcelCalculatorExample is now shown under Files>Applications in the Application Deployment Tool. Click ExcelCalculatorExample to select it. In the File menu, click New, and then click Web Component.

  8. The New Web Component Wizard opens. Bypass the Introduction by clicking Next.

  9. In WAR File General Properties, enter ExcelServlet as the WAR Display Name and click the Add button.

  10. The Edit Contents of ExcelServlet dialogue box opens.

    Browse to the ExcelCalculatorExample.class file and click Add to add it to the Contents of ExcelServlet. Browse to the ExcelCalculator.html file and click Add to add it to the Contents of ExcelServlet. Click Next.

  11. Ensure that Servlet is selected as the type of web component you are creating. Click Next.

  12. Select ExcelCalculatorExample as the Servlet Class. Enter ExcelCalculator as the Web Component Name. Click Next.

  13. Click Next on the Component Initialization Parameters page.

  14. If you look at the code for ExcelCalculator.html, you will see the action of the form is using an alias to connect to the servlet. In this step the alias is added to the application. Click Add and enter ExcelCalculatorAlias under Component Aliases.

    Click Next, then click Finish to complete the New Web Component Wizard.

  15. Select ExcelCalculatorExample in the left panel. Click the Web Context tab in the right panel and enter ExcelServlet as the Context Root.

  16. From the Tool menu, select Deploy. Click Next to skip past the Introduction.

  17. Ensure that ExcelServlet is shown as the Context Root. This is very important.

    Click Next and then click Finish.

Note: This example uses version 1.3 of the J2EE Reference Implementation. If you are using a more recent version like 1.4 or higher, you will need to perform the following three steps for the example to run.

  1. Select ExcelServlet from the left panel of the deploytool window.
  2. Under the General tab, click edit.
  3. From the file chooser that pops up, add excel.jar and jintegra.jar.

       

Run the example

After you have deployed the example successfully, open your Web browser and enter http://localhost:8000/ExcelServlet/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.