• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

init() method on servlets

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When the init method in a servlet is called? At the first request or when it is instantiated or it is instantiated when the first request is made?
 
Ranch Hand
Posts: 645
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When the init method in a servlet is called?

After Loding servlet class and executing default constructor
At the first request or when it is instantiated or it is instantiated when the first request is made?

Best time to Load a Servlet class is decided by your server depending on the server confugration.

I am not able to recollect it but there is some tag called
<load-on-startup> (may be something diff)

Cheers
-Praful
[ October 05, 2004: Message edited by: Praful Thakare ]
 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
init is called only once when the servletcontext is initialised (basically when you start tomcat). <load-on-startup>1</load-on-startup> says this servlet has highest priority at loading. 2 and higher numbers are loaded after servlets with 1 are loaded. I am not sure whether this is guaranteed or just a guideline.
 
Leandro Sales
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I�m using Tomcat and if I put <load-on-startup>4</load-on-startup>, init() method is called when the context is initialized, if I don�t put, init() methos is called only whne the first request is made...
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
init will be called after executing the default constructor of the servlet, and a servlet config object shall be passed to init method,
 
reply
    Bookmark Topic Watch Topic
  • New Topic