First of all there is no such thing called constructor in case of Servlets.
There is an init() method that is called only once while the initialization
of the servlet.  For subsequent requests, only the relevant methods to
handle request are called(for example, doGet() and doPost()).
Therefore, for the very first request to the servlet, the sequence of the
method calls on the servlet would be:
1) init()
2) service() (and then may be doGet or doPost method based on whether you
have implemented the HttpServlet abstract class)
However, for subsequent requests:
1) service() method is called (and then may be doGet or doPost methods based
on whether you have implemented the HttpServlet abstract class)

Hope this clears your doubt!

----- Original Message -----
From: sushilkumar <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, April 27, 2000 9:10 AM
Subject: Re: Constructors in Servlet


> 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
> >
> >
>
___________________________________________________________________________
> > 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
> >
> >
>
___________________________________________________________________________
> > 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
>
>
___________________________________________________________________________
> 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