Monday, 13 August 2012

What is web.xml (Deployment Descriptor) in Java?

In Java, all web applications have a web.xml file, also called deployment descriptor, in the \META-INF directory. The main purpose of this file is to provide information about the web application to deploy in the container.

It can be used to declare and configure servlets belonging to the application via descriptor elements. For example, tt helps setting filters, icons or define default welcome pages too.

Here is a web.xml example:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<web-app xmlns=""

  <display-name>My Application</display-name> 
  <description>My application description</description>



It defines a web application with one servlet called MyServlet. User requests to:

are sent to MyServlet. The MyAppPath application path is typically defined in the context.xml file. Both files serve different purpose and should not be confused with each other.

No comments:

Post a comment