• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Regarding order of elements in web.xml

 
Akshay Singhvi
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Ranchers,
Do we need to respect the order of elements in web.xml?What I mean is can i declare <context-param> element after <listener> element.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The order of elements does not matter in Servlets 2.4, so you don't have to worry about that. (the order in which listeners and filters is important though)
 
Akshay Singhvi
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what should be the order of decleration for listener, fliters and servlets???
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
About Filters : The order in which filters are invoked is the order in which filter-mapping declarations that match a request URI for a servlet appear in the list of filter-mapping elements.

About listeners : The Web container registers the listener instances according to the interfaces they implement and the order in which they appear in the deployment descriptor. On application shutdown, listeners are notified in reverse order to their declarations with notifications to session listeners preceeding notifications to context listeners.
 
Akshay Singhvi
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thankx for the response, but i wanted to ask in which order do we declare elements servlet, listener, filters in web.xml?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The order of elements do not matter.
 
Akshay Singhvi
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thankx once again.Are question on order of elements in web.xml appear in SCWCD 1.4 exams?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. But I think that you have to remember the thing about "order of listeners" and "order of filters".
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic