• 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

When init() method is called?

 
Ranch Hand
Posts: 469
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When servlet is instantiated and init() method is called ?In book it is given before first client request,that means when we start the server?
 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Veena
It maybe when the web app is loaded or when servlet is first called and it can not service any requests until after the init() method is complete.
 
Veena Pointi
Ranch Hand
Posts: 469
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.Yeah,figured out it is done either during container start up or first request.This is container specific.
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
init() is called either at web container start up or first request but there are some protocals which insure that it is called at startup
SCJP 1.4
 
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

If the <servlet> element has a <load-on-startup> then the servlet is initialized at the time of server startup/(re-)deployment of application. At this time the init() method is called. Other-wise prior to first request is received for this servlet.

Thanks
 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even if <load-on-startup> is not specified in the DD, it depends on the web-container when it wnats to load the servlet class, either when the server is started, at startup , or when the first request comes in. My servlet's init() method is called whne the server starts up even when it does not have any <load-on-startup> associated with it.
[ July 12, 2006: Message edited by: Sumita Padiyar ]
 
It looks like it's time for me to write you a reality check! Or maybe a tiny ad!
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic