*
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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Servlets
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: 61103
    
  66

There can be more than one mapping for any servlet.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1018
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://aspose.com/file-tools
 
subject: Why there is a seperation between configuring and Mapping a servlet in the web.xml file?