On Thu, 27 Apr 2000, P.Yesudason wrote:
> What is happening man.....
>
> I am sure there is no concept of constructors in Servlet ..It is
> given in books.
Well then the books you have read are either misleading or incorrect.
> If yes Try to give the details ...seems to be intresting
Take a look at Thomas Schuchert's and Andy Bailey's responses in this
thread -- they have had the most accurate answers (as much as I can
remember the entire thread).
Basically, servlets are just like any other Java object, so they have
a constructor. The thing is, in the way that servlets are normally
used, the constructor is of no practical use. "Normally used" means
dynamically created by the servlet engine, not using "new". And when
a class is dynamically created, there is no way to pass arguments to
the constructor[1], so the constructor can't really do anything.
That's why the init() method was provided.
[1] I believe this has changed in Java 1.2, but I'm not 100% sure how
that impacts all this -- basically I think it doesn't.
> sushilkumar wrote:
>
> > HI sandeep,
> > Well, I think constructor will also be called only once.whenever there is a
> > request for the servlet , the servlet engine will start separate thread to
> > service that request and then only constructor or init() method will be
> > called.
> >
> > Please correct me if i am wrong.
> >
> > Regards,
> > Sushil
> >
> > -----Original Message-----
> > From: Sandeep Malhotra [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, April 27, 2000 6:24 PM
> > To: [EMAIL PROTECTED]
> > Subject: Re: Constructors in Servlet
> >
> > However, init() will be called only once while the initialization of the
> > servlet by the servlet container. For subsequents requests this method
> > would not be called.
> >
> > ----- Original Message -----
> > From: sushilkumar <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Thursday, April 27, 2000 8:00 AM
> > Subject: Re: Constructors in Servlet
> >
> > > Hi Sanjay ,
> > > I think init() method in servlet will do the same thing what a constructor
> > > will do .
> > > So what is the need for a constructor in Servlet.
> > >
> > > Regd,
> > > Sushil
> > >
> > > -----Original Message-----
> > > From: Rohan Sud [mailto:[EMAIL PROTECTED]]
> > > Sent: Thursday, April 27, 2000 5:21 PM
> > > To: [EMAIL PROTECTED]
> > > Subject: Re: Constructors in Servlet
> > > Importance: High
> > >
> > >
> > > Hi Sanjay ,
> > > Yes u can have constructors in Servlets . They are called before
> > the
> > > init method is called.
> > >
> > > Rgds,
> > > Rohan
> > >
> > > -----Original Message-----
> > > From: Sanjay Kumar [mailto:[EMAIL PROTECTED]]
> > > Sent: Thursday, April 27, 2000 5:14 PM
> > > To: [EMAIL PROTECTED]
> > > Subject: Constructors in Servlet
> > >
> > >
> > > Hello friends,
> > > Is it possible to have constructors in Servlets?
> > > If yes when is it called?
> > >
> > > Waiting for your valuable suggestion.
> > >
> > > Thanks
> > > Sanjay
> > >
> >
>
Milt Epstein
Research Programmer
Software/Systems Development Group
Computing and Communications Services Office (CCSO)
University of Illinois at Urbana-Champaign (UIUC)
[EMAIL PROTECTED]
___________________________________________________________________________
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