aspose file tools*
The moose likes Servlets and the fly likes Use of web.xml file for deploying a servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Use of web.xml file for deploying a servlet" Watch "Use of web.xml file for deploying a servlet" New topic
Author

Use of web.xml file for deploying a servlet

shivang sarawagi
Ranch Hand

Joined: Jun 19, 2008
Posts: 148
Can anyone tell me what is the use of a web.xml file, which is a deployment descriptor, while using a servlet ??

Is it mandatory to make a xml file for every servlet class ??
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61654
    
  67

No, a single web.xml describes the servlets for the entire web app.

Within it, you must declare each servlet and its mapping. (Unless using Servlets 3, where you can substitute annotations.)


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Miku Ranjan
Ranch Hand

Joined: Oct 11, 2011
Posts: 98
Hi,
Yes Bear is right, if you are not using annotation base servlet then you have to mention your servlet along with the mapping in the web.xml file
If you will use eclipse like any ide for creating your servlet that part done automatically by the IDE.
Ankush Kaundal
Ranch Hand

Joined: May 12, 2011
Posts: 36

Web.xml is the place where the web server container will check for the mapping of the servlet name to its class and accordingly handles the task to that servlet and so the flow goes on.
Karthikeyan Nadanasabapathy
Greenhorn

Joined: Dec 13, 2011
Posts: 11

web.xml is the deployment descriptor, can also be called the heart of any web application where all servlets are mapped.
 
wood burning stoves
 
subject: Use of web.xml file for deploying a servlet