Actually, what I remember from the early days of Servlets, it is because the Servlet API is interface based, and you can't specify constructors in a Java interface.  The developers decided to use a method that they can specify in the interface contract.
  (*Chris*)

On 9/1/05, Nic Ferrier <[EMAIL PROTECTED]> wrote:
Sreenath N <[EMAIL PROTECTED]> writes:

> Reason might be init() method needs a ServletConfig object to be passed
> which is used for retreving the init-params and the container can't expect
> the user to write a constructor which takes the ServletConfig object
> .

No. Clearly this is wrong, type checking can enforce that requirement:

   public abstract class Servlet
   {
       public Servlet(ServletConfig sc)
       {
          // do some stuff
       }


       // do some stuff
   }


The reason a servlet has an init method, as opposed to a constructor
is that a constructed instance of a servlet can be deployed and
undeployed from a container several times during it's lifetime.


Nic Ferrier
http://www.tapsellferrier.co.uk

___________________________________________________________________________
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

___________________________________________________________________________ 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

Reply via email to