• 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

init() called for the first HTTP request, why not earlier?

 
Ranch Hand
Posts: 375
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It seems the init() method from the Servlet interface is called when the first HTTP request is made. This means that the first client always incurs the overhead of all the initialisation. Is it possible to set the servlet container to invoke init() in a web application as soon as the server (Tomcat) is started, rather than it sitting idle waiting for a request and then invoking init()? I can understand it having to compile JSP files (although you can pre-compile them), but I do quite a bit of I/O to setup the environment for the webapp in init() and don't want the first client to have to wait even longer. I would like the application to be 100% ready as soon as its started without having to fire up a browser to make a request, which does the initialisation before its _ready_ for production.
[ May 18, 2005: Message edited by: Kashif Riaz ]
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Lookup "load-on-startup".
It's an entry in the servlet declaration in your web.xml file.
 
K Riaz
Ranch Hand
Posts: 375
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ah, thats _exactly_ what I need. Thank you Ben. Do you know where I can find a list of all possible tags which can be used in a web.xml? I might find some hidden gems like this.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, the servlet spec.
Link in my signature.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic