• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Order inside the tag - MANDATORY?

 
Manikandan Jayaraman
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Is the order of elements inside a tag strictly to be followed?

I mean for example:

===
<mime-mapping>
<extension>txt</extension>
<mime-type>text/plain</mime-type>
<mime-mapping>
===

Should "extension" come before "mime-type" ? If the order is not required to be followed, I hope it applies to all the tags.

Can someone explain?
 
Bryan Basham
author
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Manikandan,

In the servlet v2.3 specification, the web.xml DTD did in fact verify the proper tag ordering. However, in servlet v2.4 this ordering is no longer validated. My guess why this was done is to allow the developer to group related declarations together. For example, if you were to declare 20 <servlet> definitions and followed by 20+ <servlet-mapping> definitions, it might be confusing to read the DD. However, in v2.4 the developer can group the <servlet> and <servlet-mapping> declarations together. Thus enhancing readability of the DD.

HTH,
Bryan
 
Manikandan Jayaraman
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the clarifcation Bryan!

Yes, the advantage what you mentioned is a worthy one. Also, if you consider the tag orderings inside a tag, like the one I mentioned there ... between the extension tag and mime-type ... there is no point in enforcing that extension should precede mime-type.

It infact poses more work on the deployer to remember and define it in proper order. This Makes the DD non-user-friendly.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic