This week's book giveaway is in the General Computing forum.
We're giving away four copies of Learning Regular Expressions and have Ben Forta on-line!
See this thread for details.
Win a copy of Learning Regular Expressions this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Servlet mapping Problem  RSS feed

 
Ranch Hand
Posts: 634
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why do we placed servlet mapping outside the servlet tag and not inside ?
we do mapping for a specific servlet ,then why so ?
 
Sheriff
Posts: 9613
37
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can map a servlet to more than one paths so if the mapping is separate, you can decide url matching more flexibly by ordering the servlet-mapping declaration in the order you want the servlets to match an incoming request. Something like this
 
Mohit G Gupta
Ranch Hand
Posts: 634
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i still didn't get it

 
Ranch Hand
Posts: 252
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Interesting question. Not sure why the Sun engineers designed it this way, but they could have put the <url-pattern> right inside the <servlet> tag, couldn't they? I don't see a reason why theoretically that wouldn't work. Allowing multiple <url-pattern> tags could give the flexibility of mapping different kinds of urls to the same servlet, that Ankit is talking about.

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Probably, from maintainability viewpoint, they kept <url-pattern> tag separate from <servlet>. If its a part of <servlet>, imagine what you'd need to do if you later want a url path to be handled by a different servlet (existing or a new one). You'd have to delete the <url-pattern> from the current <servlet> and make a new entry in the other <servlet>. Instead, keeping this tag in a separate <servlet-mapping> tag gives you the ease of maintenance by being able to change just the name of the servlet without touching other parts in the descriptor.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!