File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Why there is a seperation between configuring and Mapping a servlet in the web.xml file? 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 "Why there is a seperation between configuring and Mapping a servlet in the web.xml file?" Watch "Why there is a seperation between configuring and Mapping a servlet in the web.xml file?" New topic
Author

Why there is a seperation between configuring and Mapping a servlet in the web.xml file?

rajesh uppiliappan
Greenhorn

Joined: Nov 07, 2012
Posts: 1
Why we configure and Map servlets separately using the <servlet> and <servlet-mapping> tags.
for eg.


instead we can do like


what is the reason behind this seperation?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56191
    
  13

There can be more than one mapping for any servlet.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1004
Separation of concerns.
DRY (don't repeat yourself)

probably a few other programming guidelines could be applied, but those are the main two.

There are two distinct concepts here.
1 - "Servlet" defines a module that can handle a request, and gives a response
2 - "Servlet-mapping" tells the container "which servlet should I invoke when the user calls this URL"

 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Why there is a seperation between configuring and Mapping a servlet in the web.xml file?
 
Similar Threads
The requested resource () is not available.
how to resolve the problem with Deploying this war file ?
URL-Pattern mappings must contain /servlet/?
The requested resource is not available
Help needed to 'Forward' Servlet to Servlet