Oracle DBA Tips Corner |
|
Deploying Java Servlets and JSPs using the Oracle HTTP Server - (Oracle 8i)
by Jeff Hunter, Sr. Database Administrator
Contents
Introduction
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?
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
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
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.
Configuring a New Application
Compiling the Example Servlet
Compile the Java example servlet:
Where to Place the Example JSP File
Tesing the Application
Java Servlet Example
Example Java Code
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.
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.
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 (1.0.2.2.x). 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.
Installing the Oracle HTTP Server can (and should) be done as part of installing
the Oracle RDBMS Software.
The command to start, stop and restart the Oracle HTTP Server is called
apachectl and is located in $ORACLE_HOME/Apache/Apache/bin
% cd $ORACLE_HOME/Apache/Apache/bin
% ./apachectl start
% ./apachectl stop
In the following section, we will create a new application called
"mydemo".
$ORACLE_HOME/Apache/Apache/conf/httpd.conf # 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
$ORACLE_HOME/Apache/Jserv/etc/jserv.conf ...
ApJServMount /servlets /root
ApJServMount /servlet /root
ApJServMount /mydemo /mydemo
...
$ORACLE_HOME/Apache/Jserv/etc/jserv.properties ...
# 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.
root.properties=/u01/app/oracle/product/8.1.7/Apache/Jserv/etc/zone.properties
mydemo.properties = /u01/app/oracle/product/8.1.7/Apache/Jserv/etc/mydemo.properties
...
% mkdir /u01/app/oracle/product/8.1.7/Apache/Jserv/mydemo
% cd $ORACLE_HOME/Apache/Jserv/etc
% cp zone.properties mydemo.properties
$ORACLE_HOME/Apache/Jserv/etc/mydemo.properties ...
repositories=/u01/app/oracle/product/8.1.7/Apache/Jserv/mydemo
...
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
% javac HelloServlet.java
and save the output class file as:
$ORACLE_HOME/Apache/Jserv/mydemo/HelloServlet.class
For testing purposes, place the HelloJSP.jsp file in the
$ORACLE_HOME/Apache/Apache/htdocs directory:
% cp HelloJSP.jsp $ORACLE_HOME/Apache/Apache/htdocs
Bring up a web browser and navigate to the following URL to test
the new application.
http://localhost/mydemo/HelloServlet
Java Server Page (JSP) Example
http://localhost/HelloJSP.jsp
Example:
HelloServlet.java
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.
HelloJSP.jsp
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.
Monday, 23-Jan-2006 08:47:45 EST
Page Count: 25093