aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Why two places to define link in servlet class and url-pattern Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Why two places to define link in servlet class and url-pattern" Watch "Why two places to define link in servlet class and url-pattern" New topic
Author

Why two places to define link in servlet class and url-pattern

Chetan Sahasrabudhe
Ranch Hand

Joined: Aug 09, 2004
Posts: 75
I noticed that sun people have not normalized web.xml structure.

for servlet mapping and servlet class declaration there are two sections



I think same can be refactored to



In case of jsp file mapping one can drop servlet-class and user jsp-file tag.

Why sun is using two sctions to describe class location and url-pattern.
Please explain.


Thanks & Regards<br />Chetan
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

It's easier to organize the mappings with it separated and it also makes it easier to see the prioritizing of the URLs mappings.


A good workman is known by his tools.
Chetan Sahasrabudhe
Ranch Hand

Joined: Aug 09, 2004
Posts: 75
No so convincing response.
Any technical need or something based on scalability of J2EE thing
Manikandan Jayaraman
Ranch Hand

Joined: Sep 15, 2004
Posts: 230
Actually what we have now is the normalised structure. We have a primary(key)-foreign(key) relation between <servlet> and <servlet-mapping> through the <servlet-name> tag. Am I right?

Instead of having all the details in one place, we have split it into modules and made it cohesive. By cohesive I mean ... the work of the developer and deployer (or administrator) is now separated.

The developer just need to think about the <servlet> tag and the admin need to think about the <servlet-mapping> tag as to which url pattern will use this <servlet>.

Though there are pros and cons in all approaches, I find the current approach ok. What say experts?

Regards,
Mani


Regards,<br />Mani<br />SCJP 1.4 (95%)<br />SCWCD 1.4 (94%)
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

Originally posted by Chetan Sahasrabudhe:
No so convincing response.
Any technical need or something based on scalability of J2EE thing


Manikandan is right that the way it is now is more "normalized." My original response was mostly to this effect, stating a servlet can have multiple mappings creating one-to-many relationships. I removed that and shortened my response because the way I worded my explanation didn't sound very friendly.

Manikandan very well might also be correct that the sole motivation for the separation was to keep the roles of deployer and developer separate. This role separation in deployment descriptors is made much more obvious for EJBs (SCBCD) but that's mainly because EJBs were intended to be used as reusable, pluggable components that could be deployed in multiple ways.

But to explain my earlier point: it is also easier the way it currently stands. For example, it is possible for a requested URL to match more than one mapping. Which one mapping then will pick up the request? It's easier for the developer (or whoever) to determine which mapping gets the request with all the mappings together.
Chetan Sahasrabudhe
Ranch Hand

Joined: Aug 09, 2004
Posts: 75
This is cool stuff dude.
I now understand why ithttp://www.javaranch.com
Professional Certification is normalized to this level
developer and deployer thing is a important point.
Good help guys.
get ready for more quetions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why two places to define link in servlet class and url-pattern