----- Original Message -----
From: Kumar Kartikeya <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, August 18, 1999 1:26 PM
Subject: instance variable in servlet
> ** Confidential **
>
> Hi !
> I am new to servlet. I wanted to know that :
>
> 1) Why constructor is not required to initialize the servlet instance ?
Because the HttpServlet default constructor is used to create an instance of
your servlet class. Supplying your
own constructor may well cause things to break.
> 2) How the servlet instance is created ?
Servlet engines use custom class loaders to create and load servlets. A
discussion about how
they actually do things would be complicated and long. There are quite a few
sites on the web where
this information can be found as well as a mountain of books.
> 3) Can we create several instances of a servlet ?
Yes you can. By implementing the SingleThreadedModel(?) interface the
servlet engine will create and pool
several instance of the same servlet. This is not recommended unless you
have no way of making your servlet thread safe.
> 4) Why we avoid constructor to initialize servlet ?
Because initialisation has to give the servlet a chance to throw Unavailable
exceptions, telling the servlet engine that
this servlet is no longer usable. Throwing exceptions in a constructor is
not a good idea (even if you can) because
the constuctor would not have completed its work, thus leaving the servlet
in an uncertain state.
> 5) What is common in servlet and Applet ?
Hmm, what are the differences would be better.
Applets are client side components that run in browsers and generally use
the AWT for displays.
Servlets are server side components that run behind a web server. They don't
generally use the AWT for anything
although there are times when you need to.
The classes are superficially similar in that they both use an init method
and a destroy method (overriding an applet destroy
method is NOT recommended at all, but very useful for servlets).
Applets generate http requests to servers (usually) while servlets service
http requests.
> thanks in advance..
>
> Kumar
>
I would recommend you buying Jason Hunter's book Java Servlet Programming to
learn about Servlets (and how to make
Applets talk to them as well)
Hope this helps
Andy Bailey
___________________________________________________________________________
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