Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Order of listerner in web.xml

 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Is it necessary that the <listener> element in the DD needs to appear before any of the <servlet> elements for the container to properly instantiate the listener classes first? I read this is a question but HFSJ does not mention anything like this.

Please let me know.
Regards
Sanjeev
 
Ranch Hand
Posts: 310
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No
 
Sanjeev BhimaRao
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Sreeraj.

Even the Javaranch mock has a similar question and it says that the listener needs to be above the servlet element.

Have you tried this out ?

Regards
Sanjeev
 
Ranch Hand
Posts: 292
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Elements in the DD can appear in any arbitrary order

Can you post the original question itself?
 
Sanjeev BhimaRao
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, I got the issue. This is the original question

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

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

I had marked "1" as the answer, assuming "servlet-mapping" would be there. That's the reason I went wrong. The result is "3".
 
Ranch Hand
Posts: 572
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ordering of DD elements are not necessary in latest version i.e. 2.4
 
It's a tiny ad only because the water is so cold.
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic