Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

servlet/listener order in deployment descriptor

 
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
 
Ranch Hand
Posts: 1512
  • 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.
 
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.
 
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: 1512
  • 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.
 
    Bookmark Topic Watch Topic
  • New Topic