There is no difference from a standard servlet in terms of writing it,
except for one addition - you have to write an init procedure. Then to make
it load on startup, you need to modify your web.xml file to have the
container do this process. The prototypes for the functions and the
additions to web.xml are listed below.

Regards,
Paul

Here is the prototype (and comments taken from the servlet api
documentation) :

public void init(ServletConfig config) throws ServletException
//Called by the servlet container to indicate to a servlet
//that the servlet is being placed into service. See
// Servlet.init(javax.servlet.ServletConfig).

-- OR --
public void init() throws ServletException
// A convenience method which can be overridden so that there's
// no need to call super.init(config). Instead of overriding
// init(ServletConfig), simply override this method and it
// will be called by GenericServlet.init(ServletConfig config).
// The ServletConfig object can still be retrieved via getServletConfig().


Here are the web.xml changes.

<servlet>
        <servlet-name>catalog</servlet-name>
        <servlet-class>com.mycorp.CatalogServlet</servlet-class>
        <init-param>
                <param-name>catalog</param-name>
                <param-value>Spring</param-value>
        </init-param>
        <!-- This is the additional line to make it load. The number specified is
             up to you. It just indicates a relative oridering of the servlets
             which are loaded. Lower numbers are loaded first. If not specified
             the container can load it in any order it desires. The number must
             be a positive integer -->
        <load-on-startup>100</load-onstartup>
</servlet>



-----Original Message-----
From: Todd S Neven [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, January 30, 2001 1:13 PM
To: Paul FitzPatrick
Subject: FW: Delay in invoking first servlet




-----Original Message-----
From: Andreas Schlegel [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, January 30, 2001 1:08 PM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: Delay in invoking first servlet


Hi Paul,

in your answer toRachel you mention a "load-on-startup servlet". Do you
have/know an example how to write and implement such a servlet?

Greetings,
Andreas


Paul FitzPatrick wrote:

> I'm not sure, but I've heard on the list that there is an expensive random
> number seeding process that occurs on the first access to the server. This
> could be what you are seeing. To make this less obtrusive, you could
create
> a load-on-startup servlet which makes a request to your server so that
this
> delay is incurred automatically and not by the first human user.
>
> Regards,
> Paul
>
> -----Original Message-----
> From: Rachel Gollub [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, January 30, 2001 11:32 AM
> To: [EMAIL PROTECTED]
> Subject: Delay in invoking first servlet
>
> I've got tomcat running with apache, and everything's working fine,
> but when I invoke the first servlet from a browser, I get a 60-80
> second delay.  Everything after that is fast -- it's just that first
> servlet that's showing the delay.  It doesn't matter which servlet
> I use, or whether I <load-on-startup> -- it still happens.  Anyone
> know what's going on, or how to fix it?
>
> Thanks!
> --
> Rachel Gollub
> [EMAIL PROTECTED]
> http://www.equiltblocks.com/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, email: [EMAIL PROTECTED]
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, email: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to