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 two places to define link in servlet class and url-pattern

 
Chetan Sahasrabudhe
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's easier to organize the mappings with it separated and it also makes it easier to see the prioritizing of the URLs mappings.
 
Chetan Sahasrabudhe
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No so convincing response.
Any technical need or something based on scalability of J2EE thing
 
Manikandan Jayaraman
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic