The WEB-INF/web.xml Deployment Descriptor
The WEB-INF/web.xml file is the core configuration component of a Java Web Application. Residing within the WEB-INF directory of a WAR File, this XML document acts as a Deployment Descriptor, instructing the Servlet Container—such as Apache Tomcat, Jetty, or GlassFish—on how to manage and route traffic to the application components.
The primary responsibilities of WEB-INF/web.xml include defining Servlets and their corresponding Servlet Mapping, configuring Filters for request preprocessing, and declaring Listeners for lifecycle events. It also handles Context Parameters, Session Configuration, and Security Constraints. While the introduction of Servlet 3.0 and Java Annotations like @WebServlet made this file optional for many modern Jakarta EE projects, it remains a powerful tool for centralized configuration and overriding metadata defined in source code.
Detailed schema definitions and usage patterns can be found in the official Jakarta Servlet Specification and the Oracle WebLogic Documentation.