This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
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
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Servlets
Reply 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: 116
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: 56215
    
  13

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.)


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About 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: 30

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.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Use of web.xml file for deploying a servlet
 
Similar Threads
Servlet Instance
404 error when accessing servlet?
Can i keep a configFile in webapp?
Betterway to use global variable in webapplication
HTTP Status 404