> No, there are no constructors and destructors in servlets. But there are
two
> methods init() and destroy() that can be used as constructor and
destructor
> respectively.
>
> When servelt's instance is instantiated, init() is called immediately so
you
> can use it as constructor and you can do default initialization of
variables
> etc.
> When servlet is destroyed, destroy() method is called (ofcourse when
webserver
> is restarted.) and you can do clean up in this one.
>
>
> Regards
> Farooq Hameed
>
There is the standard constructor inherited from HttpServlet and the destroy
method which
is called explicitly when the servlet is destroyed and unless overridden it
does nothing.
It is inadvisable to try and override the standard constructor as you may be
cutting off any
implementor specific code if you forget to do super() and you wouldn't
really want to
be creating your own servlets via new either. Also, your constructor would
unlikely be called
as it would not be the same as the one the Servlet Engine expects.
Essentially you need not worry about the constructors of a servlet and
finalize is rarely used
as it has implications should things in finalize go wrong (see below). Just
get to know and
understand the various get methods, init and destroy.
All Java objects have a destructor, the finalize() method.
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html