Web Application Deployment Descriptor

The WEB-INF/web.xml file is a very important file. It is the application deployment descriptor that contains all configuration information for the application. If your application consists only of JSP and HTML files, you typically do not need to worry about this file at all. But if the application also contains servlets, tag libraries, or uses the container-provided security mechanisms, you often need to define some configuration information in the web.xml file.

The deployment descriptor is an XML file. A standard XML Document Type Definition (DTD) defines the elements it can contain and how they must be arranged. Example 4.1 shows a version of the complete DTD[10] without the comments. All elements are instead described after the example.

Example D-1. Java Web Application Descriptor DTD

<!ELEMENT web-app (icon?, display-name?, description?, distributable?, context-param*, servlet*, servlet-mapping*, session-config?, mime-mapping*, welcome-file-list?, error-page*, taglib*, resource-ref*, security-constraint*, login-config?, security-role*, env-entry*, ejb-ref*)> <!ELEMENT icon (small-icon?, large-icon?)> <!ELEMENT small-icon (#PCDATA)> <!ELEMENT large-icon (#PCDATA)> <!ELEMENT display-name (#PCDATA)> <!ELEMENT description (#PCDATA)> <!ELEMENT distributable EMPTY> <!ELEMENT context-param (param-name, param-value, description?)> <!ELEMENT param-name (#PCDATA)> <!ELEMENT param-value (#PCDATA)> <!ELEMENT servlet (icon?, servlet-name, display-name?, ...

Get Java Server Pages now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.