This article explains Creating Deployment Descriptor in a Dynamic Web Project in Eclipse JEE. Basically, a deployment descriptor is called web.xml and contains configuration information regarding a dynamic web application.
However, when we create a dynamic web project in Eclipse IDE, the web.xml file is not available by default. Therefore, we need to create this file explicitly.
Steps for Creating Deployment Descriptor in a Dynamic Web Project in Eclipse
The following steps demonstrate how to create a web.xml file.
At first, create a dynamic web project in Eclipse. In order to find, the deployment descriptor, expand the WebContent folder. Further click on the WEB-INF folder that should contain the web.xml file. As can be seen, it is not available right now.
In order to create web.xml, right-click on the project name and select the Java EE Tools option. Further, select Generate Deployment Descriptor Stub option. It will generate the desired web.xml file under the WebContent -> WEB-INF folder.
The following figure shows that our deployment descriptor is generated now.
In order to open the web.xml file, right-click on it and select the Open With-> Text Editor option.
The following listing shows the generated web.xml file.
As can be seen, the web.xml file contains a list of welcome files enclosed within the <web-app> tag. Basically, it indicates the default file that opens when a request for a directory arrives. Now that, we have this initial web.xml file, we can use it to configure our application. For instance, suppose we want to register the servlets and specify the URL patterns for these servlets, we can do it in this web.xml file. An example of registering a servlet is given here.