Bo Xu wrote:

> pedro salazar wrote:
>
> > Greetings,
> >
> > why is that my servlet when the first time is invoked, it takes about 30
> > seconds or more to start when the servlets that came in tomcat are
> > instantaneous? After the servlet container instantiated and initialized my
> > servlet, all the following requests are very fast. Is there any advice for
> > what we should do and don't do in init() method? I just initialize some
> > properties and a connection pool....
> > Well is it possible that my servlet container at any time my may shutdown my
> > servlet to release memory, and another time it will be requested to start
> > again and take another time too long to start, correct?
> >
> > How can I benchmark the time of instantiation of my servlet and the time of
> > my init method?
> >
> > System configuration:
> > -Tomcat 3.2.1
> > -JDK 1.3
> > -Linux RedHat 6.2 [kernel 2.2.18]
> > -PII400Mhz 256Mbytes
> >
> > thanks.
> > --
> > <psalazar/>
>
> Hi :-)  one of the ways is like the following:
>
> in WEB-INF/web.xml, add the following into the servlet-declaration of
> MyServlet:
> ...
> <load-on-startup>1</load-on-startup>
> ...
>
> now MyServlet will be loaded/initialized when TC startup.
>
> Bo
> June 06, 2001

Hi :-)  I forgot the following:
with TC4.0-b5,  when "<load-on-startup>1</load-on-startup>", I remember:
- MyServlet is loaded, i.e.: One Class object of MyServlet is made
- One instance of MyServlet is made, this instance is for that sevlet-declaration
   which you set "<load-on-startup>1</load-on-startup>" for
- init(...) method of this instance is invoked, then, for example, your
DBconnectionPool
   is initialized

  But:  you must use That servlet-name/servlet-mapping to invoke MyServlet,
otherwise,
  another instance of MyServlet will be made, and its init(...) will Still be
invoked,
  i.e.: "the first time" will Still be slow.

and it is possible that container will invoke int(...)/destroy() more than one
time.


Bo
July 06, 2001



Reply via email to