Understanding Deployment Descriptor in Reference with Servlets

As the name indicates deployment descriptor is a text file written in XML format for the purpose of deployment of a web application by deciding its operating parameters. Every web application has a specific deployment descriptor which governs its deployment on the server. Here we will understand deployment descriptor in reference with servlets.

Generally deployment descriptor is called web.xml and it is placed inside the WEB-INF subdirectory of web application which is at the root of the application. The structure of web.xml is like an XML document and it can be divided into three parts.
These are XML header, DOCTYPE and web-app part.

XML header is the usual header part indicating version and encoding of XML. DOCTYPE tag is used to specify the URL for the DTD file of deployment descriptor. The web-app component is further divided into three sub-components. We will understand them with the help of following example:

<?xml version-“1.0” encoding="ISO-8859-1"?>

<!DOCTYPE web-app SYSTEM "web-app_2_5.dtd">

First component of web-app is servlet-name which has the name of java servlet. Next is servlet-class component having the name of servlet class which is mypack.MyfirstservletClass here. Then we have init-param component which contains the name of initialization parameters for the servlet. These are used whenever the servlet is requested by the application.

We can declare multiple servlets in a web.xml by defining their names and corresponding class names under the servlet-name and servlet-class elements but their names should be unique across the web.xml. Also in addition to these components, we have servlet-mapping component, which maps the servlet to a url. This means that the servlet declared here will be requested when a url matching with the value in url-pattern element will be called by the web server.

So deployment descriptor contains the important data which is needed by the application at the runtime for doing the necessary configuration. Also web.xml contains vital security information which is necessary while accessing the application. It has security-constarint element for this. Also inside servlet element we have sub component security-role-ref which has the reference to name of security role assigned to the element.


SetApp - 100 Apps for everything you ever wanted to do on Mac

FREE Subscription

Subscribe to our mailing list and receive new articles
through email. Keep yourself updated with latest
developments in the industry.


Note : We never rent, trade, or sell my email lists to
anyone. We assure that your privacy is respected
and protected.


| All About Different Types of XML Editors | Generating XML Document Using JSP | How to Retrieve an Email Message Using Java Mail API | How to Send an Email Message Using Java Mail API | Transforming XML Data with XSLT | Understanding Basic Components of a JMS Program | Understanding Basic Technology of ebXML | Understanding Deployment Descriptor in Reference with Servlets | Understanding eXtensible Access Control Markup Language (XACML) | Understanding the Design Goals of XML | Understanding XML Common Biometric Format |

FREE Subscription

Stay Current With the Latest Technology Developments Realted to XML. Signup for Our Newsletter and Receive New Articles Through Email.



Note : We never rent, trade, or sell our email lists to anyone. We assure that your privacy is respected and protected.



Add to My Yahoo!

Visit XML Training Material Guide Homepage




“Amazon and the Amazon logo are trademarks of Amazon.com, Inc. or its affiliates.”

Copyright - © 2004 - 2019 - All Rights Reserved.