OC4J - Setting Up Virtual Hosts

Card Puncher Data Processing


Setup multiple host on several domains using a single IP address. (ie What is and how works a virtual host / custom domain / vanity hostnames)


This is a very basic example, it does not take into account using shared applications or event the use of .war or .ear files. This is left as an exercise for the reader.

  • Example Domains: gerardnico.com,
  • Example IP Address:


Create directories under OC4J_HOME\applications\ for each domain.

    mkdir $OC4J_HOME\applications\gerardnico

Add to the directory a index.html file.

Contents of OC4J_HOME\applications\gerardnico\index.html:

      <body bgcolor="#FFFFFF">

Create WEB-INF directories for the domains.

    mkdir $OC4J_HOME\applications\gerardnico\WEB-INF

Each WEB-INF directory should contain a web.xml file.

Contents of OC4J_HOME\applications\gerardnico\WEB-INF\web.xml






Create web-site XML file for each domain.

Contents of OC4J_HOME\config\gerardnico-web-site.xml:

    <web-site host="" port="80" display-name="gerardnico" virtual-hosts="gerardnico.com">

      <!-- The default web-app for this site, bound to the root -->
      <default-web-app application="default" name="gerardnico" />

      <access-log path="../log/gerardnico-web-access.log" />


Edit OC4J_HOME\config\application.xml. Add the following lines:

     <web-module id="gerardnico" path="../../home/applications/gerardnico" />

Edit OC4J_HOME\config\server.xml. Add the following lines:

    <web-site path="./gerardnico-web-site.xml" />

Restart OC4J and test.


Discover More
Card Puncher Data Processing
Creating a New Application J2ee Web Site in OC4J

If you want to create virtual host of a web site without j2ee application, look at this article : HelloWorld...
Card Puncher Data Processing
Oracle Containers for J2EE (OC4J)

OC4J is a Java application server. It's composed with , so a lot of configuration for are the same for . This Java application server is a slimmed-down version of the better-known Oracle Application...

Share this page:
Follow us:
Task Runner