AddressBook/web/WEB-INF/web.xml

Notes

Purpose
web.xml is the deployment descriptor file. It is held in the application's WEB-INF directory. It defines a number of parameters that are used when the web application is deployed into the Tomcat Servlet/JSP container.

display-name
display-name configures the web application's display name. The following lines set AddressBook's display name to "AddressBook Web Application":

    <display-name>AddressBook Web Application</display-name>
        

description
description configures the web application's description. The following lines set AddressBook's description to "This application maintains an AddressBook database.":

    <description>This application maintains an AddressBook database.</description>
        

listener
listener configures the web application so that a servlet context listener is executed when the web application is starting up and when the web application is shutting down. The following lines set AddressBook's servlet context listener to
AddressBook.ContextListener:

    <listener>
        <listener-class>AddressBook.ContextListener</listener-class>
    </listener>
        

welcome-file-list
welcome-file-list configures the web application's entry point. The default welcome-file-list preferences are set in Tomcat's conf/web.xml file. Using your favourite text editor, take a look near the end of your conf/web.xml file. You should find the following:

    <!-- ==================== Default Welcome File List ===================== -->
    <!-- When a request URI refers to a directory, the default servlet looks  -->
    <!-- for a "welcome file" within that directory and, if present,          -->
    <!-- to the corresponding resource URI for display.  If no welcome file   -->
    <!-- is present, the default servlet either serves a directory listing,   -->
    <!-- or returns a 404 status, depending on how it is configured.          -->
    <!--                                                                      -->
    <!-- If you define welcome files in your own application's web.xml        -->
    <!-- deployment descriptor, that list *replaces* the list configured      -->
    <!-- here, so be sure that you include any of the default values that     -->
    <!-- you wish to include.                                                 -->

    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>Home.jsp</welcome-file>
    </welcome-file-list>
        

It is possible make global changes to your Tomcat configuration by amending Tomcat's conf/web.xml file, but I do not recommend this. Much better is to set an individual web application's welcome-file-list preferences to the required value in the web application's own web.xml file. The following lines set AddressBook's entry point to Home.jsp:

   <welcome-file-list>
        <welcome-file>Home.jsp</welcome-file>
    </welcome-file-list>
        

Complete Source Code


<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>

    <display-name>AddressBook Web Application</display-name>

    <description>This application maintains an AddressBook database.</description>

    <listener>
        <listener-class>AddressBook.ContextListener</listener-class>
    </listener>

    <welcome-file-list>
        <welcome-file>Home.jsp</welcome-file>
    </welcome-file-list>

</web-app>