Win a copy of Getting started with Java on the Raspberry Pi this week in the Raspberry Pi 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Liutauras Vilda
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Piet Souris

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.
 
I don't even know how to spell CIA. But this tiny ad does:
Low Tech Laboratory
https://www.kickstarter.com/projects/paulwheaton/low-tech-0
reply
    Bookmark Topic Watch Topic
  • New Topic