• 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

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

 
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?
 
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
 
Ranch Hand
Posts: 207
jQuery Eclipse IDE Firefox Browser
  • 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
 
Creator of Enthuware JWS+ V6
Posts: 3346
303
Android Eclipse IDE Chrome
  • 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
 
Won't you please? Please won't you be my neighbor? - Fred Rogers. Tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic