Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Servlet Initialization

 
Reema Patel
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,
When a servlet container is started, it looks for a Deployment Descriptor (DD) file- web.xml.
Is it true that for every registered servlet, the container will instantiate it. Put simply, say I have two servlets: A and B. Only A is registered in the DD web.xml file (no, <load-on-startup> tag). When the container is started, is it that only servlet A is instantiated, or do i need to put <load-on-startup> to make sure the servlet A is instantiated? And, what happens to Servlet B which is not registered in web.xml file? is it also instantiated when s container is started or when it's requested for the first time?

Any help shall be highly appreciated.

Thanks,
Reema
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Only the servlets having a load-on-startup will be initialized on startup. The others will be when they are first accessed.

Hm, how would you even access servlets that have no entry in web.xml - are you using the invoker servlet?
 
Reema Patel
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ulf,
Thanks for the post.

Yes, I'm using the invoker servlet.

Thanks,
Reema
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!