Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

<listener> DD tag - order in web.xml?

 
Paul Statham
Ranch Hand
Posts: 60
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

Using one of the mock exam questions on this very site (Question Bank ID:52) which says


<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?

a. Provide a Log Servlet for the entire application.
b. Create a listener as defined by the com.javaranch.LogListener class.
c. Log all session information as they occur.
d. The webapp will not be loaded due to a parse exception of the DD.


I would have chosen D, but the answer is B.

But according to this page: http://download.oracle.com/docs/cd/E13222_01/wls/docs81/webapp/app_events.html#178122


The <listener> element must directly follow the <filter> and <filter-mapping> elements and directly precede the <servlet> element


Which is right?
 
Stoian Azarov
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmmm, this is interesting!

The link you posted is for WebLogic Server, so I suppose that this requirement is specific for this implementation of the container, because I made a quick check in the Servlet specification 2.4. and there it is stated that sub elements in <web-app> tag can be in any order:

SRV.13.2 Rules for Processing the Deployment Descriptor
"The sub elements under web-app can be in an arbitrary order in this version of
the specification."

Maybe someone else with more experience can confirm that.

Regards
 
Piyush Joshi
Ranch Hand
Posts: 207
Eclipse IDE Firefox Browser jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't have more experience but I have been trying listener examples for WCD preparation, and got no problem with the ordering of <listener> element. I usually put in the same order as given in the question here . I am using Tomcat 7.
 
Paul Statham
Ranch Hand
Posts: 60
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
^ That's good enough for me, thank you
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2534
113
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The order was important in previous servlet specifications (2.3 and before)

Regards,
Frits
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic