• 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: 64718
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
Posts: 1692
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