• 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
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Question on Deployment descriptor - Order of Listeners and Servlets

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does the order of Listeners and Servlets matter in DD ?

I came across this question (in italics below) on JavaRanch Mock exam and as per it the order does matter. But on Pg 174 of HFSJ, I see a DD with "listener" element after "servlet" element. Any thoughts ??

<web-app>
<servlet>
.....
</servlet>
<listener>
<listener-class>com.javaranch.LogListener</listener-class>
</listener>
</web-app>

The above entry in the Deployment Descriptor(DD) will result in which of the following?


Answer: The webapp will not be loaded due to a parse exception of the DD.

Explanation: The ordering of the DD is listener then servlet.
 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The question in JavaRanch targes Servlet spec 2.3. In 2.3, <listener> must appear before <servlet> element in deployment descriptor. As of 2.4, the order of <servlet> and <listener> does not matter.
 
Get out of my mind! Look! A tiny ad!
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!