DBA Tips Archive for Oracle


Deploying Java Servlets and JSPs using the Oracle HTTP Server - (Oracle 8i)

by Jeff Hunter, Sr. Database Administrator


  1. Introduction
  2. What are the differences between JServ and Oracle Servlet Engine?
  3. Installing Oracle HTTP Server
  4. Starting and Stopping the Oracle HTTP Server
  5. Configuring a New Application
  6. Compiling the Example Servlet
  7. Where to Place the Example JSP File
  8. Tesing the Application
  9. Example Java Code


The following article is a summary of the steps required to successfully configure and deploy Java Servlets and JSPs to the Oracle HTTP Server. The Oracle HTTP Server I refer to in this article is the one that comes standard on the Oracle8i and Oracle9i database CDs.

The Oracle HTTP Server is a valuable tool for developing CGI or Java applications that can access the database. Most of the configuration options required for the Oracle HTTP Server are built during the Oracle install.

What are the differences between JServ and Oracle Servlet Engine?

OSE was introduced at about the same time as JServ. JServ is a Java Servlet and JSP container (implementation) that used to come with Apache (several years ago), and is installed by default with 9iAS Release 1 ( JServ also comes with the Oracle8i/9i RDBMS CDs and generally serves as a component to other Oracle products. For example, Oracle Management Server (OMS) will come with a pre-configured Oracle HTTP Server that can be used for web bases reporting and administration.

Here is an overview of what is included in the Oracle8i release of JServ.

Oracle Servlet Engine (OSE) works as a specialized Web server, designed as a scalable servlet container inside the Oracle8i database. The servlet classes are loaded into Oracle8i and Oracle9i, and published in a JNDI namespace inside the database. A servlet runner handles HTTP requests, instantiates published servlets in sessions, and invokes servlet methods. Oracle Servlet Engine was also called "servlets in the database". The technology was purchased by Oracle from a company called IronFlare. Servlets in this design required use of Oracle's JVM built into the database. The JVM database option was called "JServer" in Oracle8i and "Oracle JVM" in Oracle9i.

Keep in mind that due to problems with the efficiency of calling servlets inside the database, Oracle has dropped support for the Oracle Servlet Engine as of Oracle 9.2.0.

Installing Oracle HTTP Server

Installing the Oracle HTTP Server can (and should) be done as part of installing the Oracle RDBMS Software.

When installing Oracle8i, at the "Available Product Components" panel, ensure that the following components get installed:

When installing Oracle9i, at the "Available Product Components" panel, ensure that the following components get installed:

After installation, all Apache and JServ files will be stored under $ORACLE_HOME/Apache.

Starting and Stopping the Oracle HTTP Server

The command to start, stop and restart the Oracle HTTP Server is called apachectl and is located in $ORACLE_HOME/Apache/Apache/bin

Keep in mind that if you configure the Oracle HTTP Server on a port lower than 1024, starting and stopping the server will have to be done as the UNIX "root" user account.

    % cd $ORACLE_HOME/Apache/Apache/bin
    % ./apachectl start
    % ./apachectl stop

Configuring a New Application

In the following section, we will create a new application called "mydemo".
  1. Check and change the file httpd.conf (only if necessary). The Oracle installer performs most of the necessary configuration for you by default. The only thing I typically change in this file is the port the Oracle HTTP Server will listen on. While the default port is 7777, I change this to port 80.

    # Include the configuration files needed for jserv
    include "/u01/app/oracle/product/8.1.7/Apache/Jserv/etc/jserv.conf"
    # This port is used when starting without SSL
    Port 80
    Listen 80

  2. When creating the new application "mydemo", you will need to change the following two files to alert the Oracle HTTP Server to the presence of our new application. The changes I made to these files are in bold.


    ApJServMount /servlets /root
    ApJServMount /servlet /root
    ApJServMount /mydemo /mydemo

    # List of servlet zones Apache JServ manages
    # Syntax: zones=[servlet zone],[servlet zone]... 
    # (Comma separated list of String)
    # Default: NONE
    zones=root, mydemo
    # Configuration file for each servlet zone (one per servlet zone)
    # Syntax: [servlet zone name as on the zones list].properties=[full path to configFile] (String)
    # Default: NONE
    # Note: if the file could not be opened, try using absolute paths.
    mydemo.properties = /u01/app/oracle/product/8.1.7/Apache/Jserv/etc/mydemo.properties

  3. Create a directory for the new application.
      % mkdir /u01/app/oracle/product/8.1.7/Apache/Jserv/mydemo

  4. Create a new configuration file mydemo.properties by copying zone.properties.
      % cd $ORACLE_HOME/Apache/Jserv/etc
      % cp zone.properties mydemo.properties

  5. Edit the new mydemo.properties and change the repositories entry near the begining of the file:



Compiling the Example Servlet

The example servlet HelloServlet.java (provided at the end of this article) will need to be compiled. Ensure that your CLASSPATH environment variable contains the servlet.jar library:

  % CLASSPATH=.:$ORACLE_HOME/jis/lib/servlet.jar
  % export CLASSPATH

Compile the Java example servlet:

  % javac HelloServlet.java
and save the output class file as:

Where to Place the Example JSP File

For testing purposes, place the HelloJSP.jsp file in the $ORACLE_HOME/Apache/Apache/htdocs directory:
  % cp HelloJSP.jsp $ORACLE_HOME/Apache/Apache/htdocs

Tesing the Application

Bring up a web browser and navigate to the following URL to test the new application.

Java Servlet Example

Java Server Page (JSP) Example

Example Java Code

An example Java Servlet that can be used to test the Oracle HTTP Server. Ensure to download this file (i.e. right-click link, and choose "Save Target As...") instead of directly clicking the link.
An example Java Server Page (JSP) file that can be used to test the Oracle HTTP Server. Ensure to download this file (i.e. right-click link, and choose "Save Target As...") instead of directly clicking the link.

Copyright (c) 1998-2018 Jeffrey M. Hunter. All rights reserved.

All articles, scripts and material located at the Internet address of http://www.idevelopment.info is the copyright of Jeffrey M. Hunter and is protected under copyright laws of the United States. This document may not be hosted on any other site without my express, prior, written permission. Application to host any of the material elsewhere can be made by contacting me at jhunter@idevelopment.info.

I have made every effort and taken great care in making sure that the material included on my web site is technically accurate, but I disclaim any and all responsibility for any loss, damage or destruction of data or any other property which may arise from relying on it. I will in no case be liable for any monetary damages arising from such loss, damage or destruction.

Last modified on
Thursday, 18-Nov-2010 18:35:27 EST
Page Count: 33303