In this document we walk you through all the steps you must take to deploy the sample Servlet into TomCat 3.2.3 Servlet Container.
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
This section explains how you can run the ExcelCalculatorExample on Jakarta TomCat 3.2.3. Because this example Servlet is using jintegra.jar and excel.jar, you need to set the CLASSPATH environment variable 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 the 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. After you have finished compiling the proxy files and the ExcelCalculatorExample.java, you are ready to deploy the Servlet.
Ensure that you have you have installed the J-Integra® license.
Create the deployment directory: Create a directory called ExcelExample in the webapps directory of your TomCat folder. In the ExcelExample directory, create two directories named META-INF and WEB-INF. In the WEB-INF directory 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 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) when you download J-Integra®.
<!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) and save it in the META-INF directory.
Copy ExcelCalculatorExample.class to WEB-INF/classes.
Copy ExcelCalculator.html to ExcelExample.
If you would like to share the jar files used in this example (jintegra.jar, and excel.jar), follow the instruction on Setting up the environment to run a JSP and/or Servlet file. Otherwise create a lib directory under WEB-INF and copy excel.jar, and jintegra.jar on this directory.
After you finished putting these files on the correct place, your directory structure looks like this:
Now you need to add this new servlet to server.xml. Go to the conf directory and open server.xml.
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> |
Shut down the TomCat Server by entering this command:
shutdown
Re-start the servlet container by entering this command:
startup
Open your Web browser and enter http://localhost:8080/ExcelExample/ExcelCalculator.html as the URL
Type in 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.