Title
Configuring default files <welcome-file> in OC4J and <DirectoryIndex> in OHS

Date
2008-07-16

Summary
You can configure your OC4J web application or OHS to include a default "welcome" file, meaning that if a user navigates to a URL without explicitly specifying a file name (e.g., http://server/ instead of http://server/hello.html), the user will be defaulted to the "welcome" file specified.

Below are various examples of what can be used or configured.

Details
1. OHS can be configured to include a DirectoryIndex directive in $ORACLE_HOME/Apache/Apache/conf/httpd.conf. This only applies to subdirectories under $ORACLE_HOME/Apache/Apache/htdocs and not to any of your OC4J applications.
#
# DirectoryIndex: Name of the file or files to use as a pre-written HTML
# directory index.  Separate multiple entries with spaces.
#
<IfModule mod_dir.c>
    DirectoryIndex index.html
</IfModule>

2. A welcome-file can be specified in the application's web.xml file. The web.xml files are typically deployed to $ORACLE_HOME/j2ee/<containername>/applications/<applicationname>/<contextname>/WEB-INF/web.xml

Welcome files are configured at the application level in OC4J.

In the example below, the default file is index.jsp:
<welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
</welcome-file-list>

Alternatively, a directory can be specified:
<welcome-file-list>
    <welcome-file>/Login</welcome-file>
</welcome-file-list>

Multiple files can be specified, so if the first is not found, it traverses the list:
<welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>index.html</welcome-file>
    <welcome-file>example.jspx</welcome-file>
</welcome-file-list>

The welcome-list directive can be dropped altogether and a servlet-mapping can be used instead:
<servlet>
    <servlet-name>SomeServlet</servlet-name>
    <servlet-class>somepkg.SomeClass</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>SomeServlet</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>

3. If the JSP file in the welcome-file-list is in a sub-directory, the following is an example of what can be used:
<welcome-file-list>
    <welcome-file>web/somedir/myindex.jsp</welcome-file>
</welcome-file-list>

The directory web/somedir is relative to your web module home.

Applicable Versions
Oracle Application Server 9i
Oracle Application Server 10g

References
http://forum.java.sun.com/thread.jspa?threadID=283180&messageID=3479996
http://www.oracle.com/technology/tech/java/oc4j/htdocs/OC4J-WEB-FAQ.html#12
Ahmed Aboulnaga

.com .com