Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

listener inside DD

 
dharmendra Rathor
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Inside web.xml file listener element should be declared first then servlet ?
TRUE
FALSE

what is answer ?
 
Padma priya Gururajan
Ranch Hand
Posts: 437
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dharmendra,
This link should help you.
http://www.coderanch.com/t/423314/java-Web-Component-SCWCD/certification/Sample-web-xml-may-useful

With regards,
Padma priya N.G.
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

As per 1.4 web.xml schema, there is no ordering constraints for the elements under <web-app>. You can define servlets, servlet-mapping, filters, listeners etc. in any order.

Thanks
 
khushhal yadav
Ranch Hand
Posts: 242
Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As per 2.4 web.xml schema, there is no ordering constraints for the elements under <web-app>. You can define servlets, servlet-mapping, filters, listeners etc. in any order.


But

Please remember, there is a order in which listeners(among themselves too), filters and servlets are loaded and unloaded at the time of startup or shutdown of application. Please refer specs.

Regards,
Khushhal
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kushhal,

The order you are talking is about the execution of the listeners and filters. It is related to the logic you want to execute in specified order.

But synthetically, there is no restriction on the order. In the old specs (2.3 and earlier), there is restrictions on the order such that you can not define listeners after the servlet entries etc.

Hope this help

Thanks
 
khushhal yadav
Ranch Hand
Posts: 242
Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Narendra,

Whatever you have written that's totally true.
But I am not talking a about the order of defining of listeners, filters and servlet as different entities. Yes I am agree with your statement In the old specs (2.3 and earlier), there is restrictions on the order such that you can not define listeners after the servlet entries etc.

But I am talking about the order in which they will be loaded and unloaded at the time of startup or shutdown of the application.
Like, first Listener classes will be loaded and initialized.
Then filter classes.
And then the servlet classes.
irrespective of the order they are defined in the deployment descriptor.

Yes among filters and listeners, the order of loading will be the order in which they are defined in the web.xml.

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