Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

servlet/listener order in deployment descriptor

 
Chad LaVigne
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just took the SCWCD mock exam on JavaRanch and got the following question:



I answered that a listener would be created as specified by the com.javaranch.LogListener class. The mock exam results said the correct answer is that the webapp will not be loaded due to a parse exception of the DD because the ordering of the DD is listener then servlet. This contradicts the examples from the Head First Servlets & JSP book which shows the listeners being defined after the servlet definitions. Also, I've created listeners that are defined after the servlets in web.xml and everything works in Tomcat 5.0.28. Which way is correct and which way does the real test expect me to answer?

Thanks,
Chad
 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe up to version 2.3 of the DTD, the order of elements in web.xml does matter. But, as of 2.4 it does not matter any longer. I am ot sure what the exam will expect as the correct answer.
 
amar verma
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe up to version 2.3 of the DTD, the order of elements in web.xml does matter. But, as of 2.4 it does not matter any longer


I tried it in tomcat4.0 , order of elements does matter.
It doesn't parse web.xml if listner tag is after servlet tag.
 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try it in Tomcat 5.X it will Work. Order of Listeners/Servlets is not a matter in Tomcat 5.X
 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Absolutely Amar, it did not parse in tomcat 4.0 because it supports/uses version 2.3 of the DTD. In which case, the order of the elements does matter.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic