wood burning stoves 2.0*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Question on Deployment descriptor - Order of Listeners and Servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Question on Deployment descriptor - Order of Listeners and Servlets" Watch "Question on Deployment descriptor - Order of Listeners and Servlets" New topic
Author

Question on Deployment descriptor - Order of Listeners and Servlets

P Rathi
Greenhorn

Joined: Feb 14, 2006
Posts: 8
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.
Connie Ky Leung
Ranch Hand

Joined: Jan 29, 2006
Posts: 42
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.


SCJP 1.4 - 91%, SCWCD - 97%, SCJP 5.0 - 83%, SCJP 6.0, OCEJWCD - 80%
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Question on Deployment descriptor - Order of Listeners and Servlets
 
Similar Threads
servlet/listener order in deployment descriptor
Question Bank ID : 52
Listeners
error in JavaRange Mock
Order Of Elements in Deployment Descriptor.