wood burning stoves*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes servlet-mapping tag in web.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "servlet-mapping tag in web.xml" Watch "servlet-mapping tag in web.xml" New topic
Author

servlet-mapping tag in web.xml

Nidhi Sar
Ranch Hand

Joined: Oct 19, 2009
Posts: 252

I have a question about the servlet mapping tag.

Does each <servlet-name>, <url-pattern> mapped pair have to be in it's own servlet-mapping root?

i.e., if I have this scenario:-


Can I write is as the following?



"A problem well stated is a problem half solved.” - Charles F. Kettering
SCJP 6, OCPJWCD
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1700
    
  25

Hi Nidhi,

Good question: you can't.

Have a look at Servlet 2.4 spec (SRV.13.4 Deployment Descriptor Diagram)
You will find nice diagrams explaining all the elements of the DD

Regards,
Frits

Ram Narayan.M
Ranch Hand

Joined: Jul 11, 2010
Posts: 247

If the latter form is the case, its tough to form the <servlet-name> and <url-pattern> pair since there is one parent <servlet-mapping> node... And when you write a XML parser for this, you will get list of <servlet-names> nodes and <url-pattern> nodes not knowing which forms which pair...

So, to ease up, the former standard is used.... In this case, you will get the list of <servlet-mapping> nodes which contains <servlet-name> and <url-pattern> pair and no confusion of mapping it... Thats why


SCJP 6 [SCJP - Old is Gold]
Nidhi Sar
Ranch Hand

Joined: Oct 19, 2009
Posts: 252

Thanks Ram. So the parent <servlet-mapping> node is what ties the pair together. That's interesting.
Frits, the diagrams look quite helpful. Thanks for sharing.
 
Don't get me started about those stupid light bulbs.
 
subject: servlet-mapping tag in web.xml