Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Order of elements in web.xml

 
Thiru Thangavelu
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Ranchers,
It has been sometime that I am returning to Javaranch after I passed my SCJP2 with 93%. Completed my preparations and while I was doing some mock exams, I came to know some of the questions and I am going to participate this forum again. Hope I will get the some good response here, as I got it for my SCJP preparation.
Here goes the question.

<context-param>
<param-name>Parameter Value</param-name>
<param-value>Parameter Name</param-value>
<context-param>

Why it is not working when I change the order like this?

<context-param>
<param-value>Parameter Name</param-value>
<param-name>Parameter Value</param-name>
<context-param>

Is it true for all the web.xml elements?
 
Vedhas Pitkar
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes the order of elements is important in web.xml as the file is parsed first when the context is initialized.If u see the tomcat logs it will show u a XML parse Exception or something-of-the-sort.
The elements are case-sensitive also.
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The order, by the way, is dictated by the DTD. So any application server that uses a validating XML parser for the web.xml file will fail to deploy applications that do not have their XML elements in the right order.
I suggest you study the DTD and learn it by rote.
- Peter
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic