Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 E-mail Us
 Oracle Articles
New Oracle Articles

 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog

 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Oracle Support

 SQL Tuning

 Oracle UNIX
 Oracle Linux
 Remote s
 Remote plans
 Application Server

 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S


 Consulting Staff
 Consulting Prices
 Help Wanted!


 Oracle Posters
 Oracle Books

 Oracle Scripts

Don Burleson Blog 









Introduction to Oracle Containers for J2EE

Oracle Application Server Tips by Burleson Consulting

Enterprise JavaBeans are J2EE software components that exist and operate in a container. The container provides all the services an EJB needs to interact with other EJBs, the client application, and the server resources. It is through the container that the client application accesses the EJB. The container lists the EJBs it holds in a Java Naming and Directory Interface. When an EJB is accessed, the container is responsible for starting the EJB and managing the execution of the request. The request could require that a new copy of the bean be instantiated, select one from a pool of instantiated beans, or use an EJB already running. The container is responsible for supporting the operation of the EJB, and this includes maintaining transactions, security, and persistence. The container may handle the database connectivity of an entity bean, or the entity bean may connect to the database using a JDBC connection. OC4J is Oracle Application Server 10g?s container for J2EE.

Servlets, JSPs, and Apache Jserv

OC4J is Oracle?s container for EJBs, servlets, and JSP processing. OC4J implements a servlet container to execute servlets. The module mod_oc4j (on the Oracle HTTP server) is the default method for communicating with OC4J to handle servlets and JSPs. Mod_oc4j communicates with the servlet container using AJP (Apache Jserv Protocol) or by a direct HTTP request. Using a direct HTTP request allows OHS to communicate through a firewall to the servlet container. However, communications using AJP between mod_oc4j and the OC4J container are not secure, so it is recommended that both OHS and OC4J be located behind a firewall. Although Oracle Application Server 10g embeds the OC4J containers in the application server, you can implement a standalone OC4J container. OC4J containers and their administration are covered in more detail in the next chapter.

Executing Servlets in OC4J

The OC4J servlet container implements the Servlet 2.3 specification. It is also 100 percent code compatible with Apache?s Tomcat. All servlets are normally deployed into the servlet container as WAR files, but they can also be manually placed in a subdirectory where the servlet container will look for them when needed. When deployed as a WAR file, the servlet container is responsible for executing the servlets contained in the WAR file, which includes uncompressing the file and installing the servlet. The servlet container also provides for high availability through automatic restart if the JVM fails. A servlet running inside the OC4J servlet container has access to the full array of J2EE APIs, including database connectivity and EJBs running in the OC4J container. The servlet container also provides the servlet access to properties included in the HTTP request.

Figure 3: Servlet running in the OC4J servlet container

Again, coding a servlet is beyond the scope of this book, but you do need to understand how servlets are maintained in the Application Server. The OC4J servlet container looks in the $ORACLE_HOME/j2ee/home/default-web-apps/WEB-INF/classes directory for servlet class files. During development, using this directory will speed the testing process because the servlet container can detect changed code and automatically recompile the servlet before executing it. To activate this feature, edit the global-web-application.xml configuration file located in the $ORACLE_HOME/j2ee/home/config directory and set development="true" as shown here:


Now when the servlet container executes the servlet, it will first check the source file (.java), and if it has changes, the servlet container will recompile the servlet with the new source code before executing it. The global-web-application.xml file sets default parameters for applications and will be discussed in detail in the next chapter. While it is effective to call the servlet?s class file directly during development, it is not recommended for a production environment for security reasons. In a production environment, servlets should be deployed in a WAR file, normally inside an EAR file.

When a web component is deployed, the WAR file contains a deployment descriptor called web.xml. This XML file is read when the servlet is started and can be used to pass initial parameters if needed. Many times the web.xml file declares a name for the servlet that is different from the servlet?s class file. In the next example, the servlet snoop is defined using the SnoopServlet class file.


If the servlet?s web.xml file declares the tag <load-on-startup>, the servlet container loads it when the container starts. Otherwise the servlet is loaded when a client requests it.

Deployment of web components (servlet/JSPs) is discussed later in this chapter as part of deploying an application.

This is an excerpt from "Oracle 10g Application Server Administration Handbook" by Don Burleson and John Garmany.

If you like Oracle tuning, you may enjoy the new book "Oracle Tuning: The Definitive Reference", over 900 pages of BC's favorite tuning tips & scripts. 

You can buy it direct from the publisher for 30%-off and get instant access to the code depot of Oracle tuning scripts.


Oracle Training at Sea
oracle dba poster

Follow us on Twitter 
Oracle performance tuning software 
Oracle Linux poster


Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  

and include the URL for the page.


Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


Copyright © 1996 -  2017

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.

Remote Emergency Support provided by Conversational