This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization 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
  • 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: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There can be more than one mapping for any servlet.
 
Stefan Evans
Bartender
Pie
Posts: 1670
10
  • 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"

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic