Which of the following files is the correct name and location of deployment descriptor of a web application. Assume that the web application is rooted at \doc-root. Select the one correct answer
-
\doc-root\dd.xml
-
\doc-root\web.xml
-
\doc-root\WEB-INF\web.xml
-
\doc-root\WEB_INF\dd.xml
To solve this question, the user needs to know the naming convention and location of the deployment descriptor for a web application.
The deployment descriptor is an XML file that contains information about the web application, such as the servlets, filters, and other components that make up the application. It is used by the web server or servlet container to configure the application at runtime.
Now, let's go through each option and explain why it is right or wrong:
A. \doc-root\dd.xml: This option is incorrect because the deployment descriptor must be located in the WEB-INF directory of the web application. Therefore, option A is not a valid location for the deployment descriptor.
B. \doc-root\web.xml: This option is incorrect because the deployment descriptor must be located in the WEB-INF directory of the web application. Therefore, option B is not a valid location for the deployment descriptor.
C. \doc-root\WEB-INF\web.xml: This option is correct. This is the correct location and naming convention for the deployment descriptor of a web application. The WEB-INF directory is a special directory that is not directly accessible from the web, so it is a secure location to store configuration files.
D. \doc-root\WEB_INF\dd.xml: This option is incorrect because the deployment descriptor must be named "web.xml" and it must be located in the WEB-INF directory of the web application. Therefore, option D is not a valid location or naming convention for the deployment descriptor.
The Answer is: C
The Java EE web application deployment descriptor must be named web.xml and placed inside the WEB-INF directory at the root of the web application, i.e. \doc-root\WEB-INF\web.xml. Placing it directly under doc-root, misspelling the directory as WEB_INF, or renaming the file to dd.xml all violate the required convention that containers look for.