• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

servlet/listener order in deployment descriptor

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 1514
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 1514
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic