On Wed, 21 Mar 2001, Maya Muchnik wrote:

> Craig,
> 
> 1/ If we will have one extra servlet whose main functions are init and destroy
> how this concerns computer resources?

The only extra resource is the fact that this servlet class is loaded,
normally for the life of the web app.  In the case of DatabaseServlet,
that is roughly 6kb.

You can minimize this by subclassing ActionServlet and overriding
init() and destroy() yourself, although you are still going to be
increasing it's size slightly.  You'll only be saving a few bytes.

> And this servlet will be idle?

Yes.

> 2/ Who is calling doGet () method of DatabaseServlet? There is no mapping for
> "database" servlet. Maybe it is automatically?

The doGet() and doPost() methods of this servlet are never called.  All
the important stuff is done in the init() method (which is called when the
web application is started because of the <load-on-startup> setting) and
the destroy() method (which is called when the web app is shut down).

NOTE:  Although most current servlet containers behave as described above,
they are not required to -- it is legal for the servlet container to take
a servlet out of service any time it wants to.  Therefore, using a
separate servlet like this has a slight risk.  It is unlikely that the
controller servlet would ever be removed, because it will be accessed a
lot.

In a servlet 2.3 environment, the recommended approach would be to use the
new application event listener API, because your context listener is
guaranteed to be called at webapp start and webapp shutdown.  However, the
current use of Struts is almost totally on containers that support 2.2, so
this isn't an option for now.

> 
> Maya
> 

Craig

Reply via email to