• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

When a servlet is instantiated?

 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
Suppose, not defining <load-on-startup> in the web.xml.
The servlet instance is created when servlet container starts up or it's not created until a request for this servlet comes?

Thanks a lot!

Hai
 
Ranch Hand
Posts: 624
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Without a <load-on-startup> configuration setting, the servlet is created the first time it is requested. If your Servlet initialization is resource intensive (say if it needs to create a large number of support objects) then the first user/client to access that Servlet will experience a delay. In such cases, you should use the <load-on-startup>. You only need to define a number -- such as <load-on-startup>1</load-on-startup> -- if the initialization order of your Servlets is important. If not, you can simply use <load-on-startup/>.
[ June 03, 2004: Message edited by: Mark Vedder ]
 
Hai Lin
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mark,
Thanks a lot to clear my confusion.

Hai
 
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Following are the exact words picked from Servlet 2.3 specification
"The servlet container is responsible for loading and instantiating servlets. The loading and instantiation can occur when the container is started, or delayed until the container determines the servlet is needed to service a request.".

Hope this clears the confusion
reply
    Bookmark Topic Watch Topic
  • New Topic