Deploying a JSP to TomCat

In this document we walk you through all the steps you must take to deploy the sample JSP into TomCat 3.2.3 Servlet Container.

The steps involved

  1. Preparation

  2. Deploy the example

  3. Run the example
  4. Setting Up the Environment

Preparation

  1. Copy the provided ExcelCalculatorJSP.html, and ExcelCalculatorExample.jsp files into a local directory that is going to be the target directory of your deployment. These files are included in your jintegra\examples\servlet-com\ServletToExcelCalculator directory when you download J-Integra®.

Deploy the example

This section explains how you can run the ExcelCalculatorExample on Jakarta TomCat 3.2.3. Because this example JSP is using jintegra.jar and excel.jar, you need to set the CLASSPATH environment so that the Tomcat Servlet Container will find the classes it needs. You can either create a batch file that sets the CLASSPATH or you can modify TomCat's startup.bat to include your CLASSPATH.

Another issue is the authentication library. On an NT machine, you need to be authenticated in order to have access to a COM object. J-Integra® comes with a native library that authenticates you automatically. The native library is located in jintegra\bin. You must add this path to your PATH environment variable. Again, either you can write a batch file to set this one or modify TomCat's startup.bat to do the job.

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

  2. Create the deployment directory: Create a directory called ExcelExampleJSP in the webapps directory of your TomCat folder. In the ExcelExampleJSP directory, create two directories named META-INF and WEB-INF. 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 example. 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 for JSP) 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>ExcelCalculatorJSP</display-name> 
    <description>no description</description> 
      <servlet> 
      <servlet-name>ExcelCalculatorJSP</servlet-name> 
    <display-name>ExcelCalculatorJSP</display-name> 
      <description>no description</description> 
      <jsp-file>/ExcelCalculatorExample.jsp</jsp-file> 
      </servlet> 
      <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) and save it in the META-INF directory.

  5. Copy ExcelCalculatorExample.jsp and ExcelCalculatorJSP.html to the ExcelExampleJSP directory.

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

  7. Now you need to add this new JSP to server.xml. Go to the conf directory and open server.xml.

  8. Add the following lines at the bottom of server.xml just before

    </ContextManager>

    <Context path="/ExcelExample"  
      docBase="webapps/ExcelExample"  
      crossContext="true"  
      debug="0"  
      reloadable="true"  
      trusted="false" > 
    </Context>

Run the example

  1. Shut down the Tomcat server by issuing this command:
    shutdown

  2. Re-start the servlet container by issuing this command:
    startup

  3. Open up your browser and enter http://localhost:8080/ExcelExampleJSP/ExcelCalculatorJSP.html as the URL.

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