Deploying a Servlet in WebSphere Application Server V4.0 AES

In this document we walk you through all the steps you must take to deploy the sample Servlet into WebSphere Application Server V4.0 AES.

The steps involved

  1. Preparation

  2. Deploy the example

  3. Authentication

  4. Run the example
  5. 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. 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 in WebSphere Application Server V4.0 AES. We are going to share the JAR files used by this servlet, so the only things that we need to create for the deployment are the servlet class file and the html file. In order to deploy the servlet onto the WebSphere Application Server V4.0 AES, we must have an EAR file that contains the WAR file for the servlet and the XML files mandated by the J2EE specification. WebSphere Application Server V4.0 AES comes with a tool called Application Assembly Tool (AAT) that helps you to create these files.

  1. You can start the AAT either from a DOS prompt or from the Windows Start menu. To run AAT from a DOS prompt, open up a DOS session and set the the path and classpath environment variables. Then go to the bin directory under the directory in which you have installed WebSphere, and enter this command:
    assembly.bat

    -or-

    Click the Start button and then click Programs>IBM WebSphere>Application Server V4.0 AES>Application Assembly Tool

    The Welcome to Application Assembly Tool dialog box opens.

    Select Application and click OK.

    The AAT creates an empty application for you.

  2. In the Display Name box, type ExcelCalculator and click Apply.

  3. In the left pane, right-click Web Modules and select New.

  4. In the New Web Module dialogue box, enter ExcelExample.war as the File name, enter /webapp/ExcelExample as the Context root, and ExcelExample as the Display Name. Click OK to add the new WAR file.

  5. The AAT now looks like this:

  6. In the left pane, open Web Modules>ExcelExample>Files. Right-click Class Files and select Add Files.

  7. In the Add Files dialog box, click Browse and select Excel_WS as the root directory

  8. Select ExcelCalculatorExample.class and click Add. Then click OK.

  9.  In the left pane, right-click Resource Files and select Add Files.

  10. In the Add Files dialog box, click Browse and select Excel_WS as the root directory

  11. Select ExcelCalculator.html and click Add. Then click OK.

  12. In the left pane of the AAT, right-click Web Components, and select New.

  13. In the New Web Component dialogue box, enter ExcelCalculator in the Component Name box. Enter Excel Calculator in the Display Name box. Select Servlet as the Component Type. Click Browse.

  14. In the Select file for Class name dialogue box, select ExcelCalculatorExample.class, and click OK.

  15. Click OK twice more to return to the AAT.

  16. Right-click Servlet Mapping and select New.

  17. In the New Servlet Mapping dialogue box, enter ExcelCalculatorAlias as the URL Pattern. Click OK.

  18. In the AAT, click on the File menu and select Save. Select Excel_WS as the directory and ExcelCalculator.ear as the file name.

  19. Now you have the EAR file that contains the WAR file and all other XML files that you need to deploy the servlet. Go to the bin directory of WebSphere and enter this command (all in one line): (We assume your ear file is in D:\Excel_WS\ExcelCalculator.ear)
    C:\WebSphere\AppServer\bin\seappinstall
    -install D:\Excel_WS\ExcelCalculator.ear -interactive false
    -configFile c:\WebSphere\AppServer\config\server-cfg.xml

  20. Now you should have the servlet installed on the server. If the WebSphere application server is running, stop it by entering this command:
    C:\WebSphere\AppServer\bin\stopserver

Authentication

  1. Start the WebSphere application server by entering this command:
    C:\WebSphere\AppServer\bin\startserver

  2. The servlet needs to have access to some class files that are in jintegra.jar and excel.jar. We did not include these files in our servlet, because we wanted to make them available to all Servlets, JSPs, and EJBs that use J-Integra®. To make them available, you need to use the Administrators Console. Open the Start menu and then click Programs>IBM WebSphere>Application Server V4.0 AES>Administrators Console

  3. Type in your password and click Submit

  4. Double-click Nodes>your computer name>Application Servers>Default Server>Process Definition.

  5. In the Process Definition window, click Environment.

  6. In the System Properties window,click New. Enter CLASSPATH as the Name. Specify the path to jintegra.jar and excel.jar as the Value. For example, if jintegra.jar and excel.jar are in D:\JLib, you must enter D:\JLib\jintegra.jar;D:\JLib\excel.jar; as the Value. Click OK.

  7. Click New. Enter PATH as the Name. Specify the path to jintegra\bin as the Value. For example, if you have installed J-Integra® in D:\JIntegra, you must enter D:\JIintegra\bin as the Value. Click OK.

  8. Click Save on the black menu across the top of the page. In the Save Configuration window, click OK.

  9. Click Exit.

  10. Stop the WebSphere application by entering this command:
    C:\WebSphere\AppServer\bin\stopserver

Run the example

  1. Start the WebSphere application server by entering this command:
    C:\WebSphere\AppServer\bin\startserver

  2. Open your browser and enter this address: http://localhost:9080/webapp/ExcelExample/ExcelCalculator.html (Note: The address is case sensitive.)

  3. Enter two numbers and click Submit.

  4. If you do not want to set the CLASSPATH on Adminstrators Console, you can set it in one of the batch files that WAS uses to initialize the environment variables. It is called setupCmdLine.bat and is located on bin directory. Open this file and add the path to your jar files at the end of WAS_CLASSPATH line. For example if you want to set the classpath for the servlet example, then this line will look like this: (Let assume your jintegra.jar, and excel.jar are in D:\JLib)

    SET WAS_CLASSPATH=%WAS_HOME%\properties;%WAS_HOME%\lib\bootstrap.jar;

    SET WAS_CLASSPATH=%WAS_CLASSPATH%;D:\JLib\jintegra.jar;D:\JLib\excel.jar;

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.