Win a copy of TDD for a Shopping Website LiveProject this week in the Testing 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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

 
Ranch Hand
Posts: 60
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
^ That's good enough for me, thank you
 
Creator of Enthuware JWS+ V6
Posts: 3398
312
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The order was important in previous servlet specifications (2.3 and before)

Regards,
Frits
 
My honeysuckle is blooming this year! Now to fertilize this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic