This week's book giveaway is in the NodeJS forum.
We're giving away four copies of Serverless Applications with Node.js and have Slobodan Stojanovic & Aleksandar Simovic on-line!
See this thread for details.
Win a copy of Serverless Applications with Node.js this week in the 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
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Vijitha Kumara

servlet startup order  RSS feed

 
Stella Kim
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's the correct order of the following statements:

1) Initialize Servlets to load on startup in the web application deployment descriptor.

2) The contextInitilized method is called on listeners implementing ServletContextListener which have been instantiated.

3) Instantiate listeners defined in the web application DD

4) Initialize filters defined in the web application DD
[ January 18, 2007: Message edited by: flytothemoon ]
 
Gowher Naik
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The correct order is as follows
First the container loads filters
Next container Loads Listeners
Then container loads sevlets
 
Amirr Rafique
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
where did the 2nd point will fall in order
 
Gowher Naik
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
write a servlet who uses ServletContextListener and filter then check which one is loaded first(listener or ServletContextListener) by using System.out.println("string") method.
 
Sayak Banerjee
Ranch Hand
Posts: 292
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The correct order is as follows
First the container loads filters
Next container Loads Listeners

Then container loads sevlets


I'm afraid that's incorrect.

This is from Servlet spec. 2.4 -- page 78

When a web application is deployed into a container, the following steps must be performed, in this order, before the web application begins processing client requests.
� Instantiate an instance of each event listener identified by a <listener> element in the deployment descriptor.
� For instantiated listener instances that implement ServletContextListener,
call the contextInitialized() method.
� Instantiate an instance of each filter identified by a <filter> element in the deployment descriptor and call each filter instance�s init() method.
� Instantiate an instance of each servlet identified by a <servlet> element that includes a <load-on-startup> element in the order defined by the load-on-startup element values, and call each servlet instance�s init() method.


[ January 19, 2007: Message edited by: Sayak Banerjee ]
 
Micheal John
Ranch Hand
Posts: 344
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes.. I think Sayak Banerjee is correct.
First.. Listeners
Second..The contextInitilized method is called on listeners implementing ServletContextListener which have been instantiated.

Third.. Filter
Fourth.. Servlet
 
Stella Kim
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anyone can confirm this ?

Filter -- then Listener ?

or

Listener -- then Filter ?
 
Ali Gohar
Ranch Hand
Posts: 572
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This has already been confirmed by the post from Sayak as he wrote the quote from Servlet 2.4 specs page 78. If its still not confirmed then see it yourself at page 78.

If you don't have the specs you can find the link here SCWCD Links
 
Stella Kim
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, sorry,
I didn't read carefully.

Thank you all
 
Anderson gave himself the promotion. So I gave myself this tiny ad:
Create Edit Print & Convert PDF Using Free API with Java
https://coderanch.com/wiki/703735/Create-Convert-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!