File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
rajesh uppiliappan
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64188
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There can be more than one mapping for any servlet.
 
Stefan Evans
Bartender
Posts: 1640
9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic