HI,

Let me add a little bit here,

a.Servlet is built purposely as helper for dynamic web app server and it the
container that control the Servlet; it is the java answer for dynamic web
page to old cgi/bin.

Servlet is loaded, initialized and created aka lifecycle ( defined in
Deployment Descriptor file ) by container.

b. As soon as there is an HTTP request by client, the container signal and
create HTTPRequest and HTTPResponse Objects, then based on the URL mapped (
in DD ) , the container allocate thread for the request thread
and pass the request/response objects to Servlet thread,

c. The container then call the servlet method service() which invoke either
doGet() or doPost() to handle
the "input" parameters feed from client ( jsp )

          GET                      GET                  GET
JSP ------> webserver ------> container ----> servlet


d. when container create a servlet object, first it load the class, then
calling
    the servlet's no-arg constructor and invoke the init() method; to remove
the
    servlet, the contstructor invoke servlet's destroy()

e. So, only the container has the access / control to call the servlet
constructor.



bb




On Tue, Mar 30, 2010 at 9:20 PM, Mihai DINCA <mihai.di...@free.fr> wrote:

>  Hi Nirmal,
>
> 1. There is a constructor somewhere in the servlet class hierarchy, but, as
> it is directly called by the server (you never make a "new" for a servlet),
> you don't care about it. When the servlet is created, the "init()" method is
> called immediately. So, if you have something to initialize, you can do it
> in "init()" (you don't need to override the constructor). If you want to
> pass parameters to the servlet you can use runtime parameters (as stored in
> the web.xml file). So you can have everything that a constructor could give
> you, but without the use of a constructor.
>
> As servlets are not supposed to contain session specific data in members,
> they could be conceived as having only static methods (they are very
> "procedural"). So no constructor would be called before using a servlet. But
> as the derived classes cannot override properly the static methods, they
> were conceived as they are. The constructor is called silently by the
> server, so that they still behave very "procedural".
>
> 2. I am not sure I know the answer.
>
> Hope it helps
> mihai
>
>
> Nirmal Kumar a écrit :
>
> Hi All,
>
> Please answer the following questions:
>
> Swrvlet      *    1. Servlet is a Java class, then why there is no
> constructor in Servlet. Can we write a constructor in Servlets?*
>
> *
> *
>
>  *                                       2. Implicit objects of JSP are
> available in destroy() method or not?*
>
>
>  -Nirmal
>                 \\\///
>              /         \
>              | \\   // |
>            ( | (.) (.) |)
> ----------o00o--(_)--o00o-------------------
> Stand up,be bold,be strong.
> Take the whole responsibility on
> ur own shoulders and know that
> U are the creator of ur own destiny.
> ------ooo0-------------------------------------
>    (   )     0ooo
>     \ (      (   )
>      \_)      ) /
>              (_/
> --
> You received this message because you are subscribed to the Google
> Groups "Java EE (J2EE) Programming with Passion!" group.
> To post to this group, send email to
> java-ee-j2ee-programming-with-passion@googlegroups.com
> To unsubscribe from this group, send email to
> java-ee-j2ee-programming-with-passion+unsubscr...@googlegroups.com
> For more options, visit this group at
>
> http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en?hl=en
>
> To unsubscribe from this group, send email to
> java-ee-j2ee-programming-with-passion+unsubscribegooglegroups.com or reply
> to this email with the words "REMOVE ME" as the subject.
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Java EE (J2EE) Programming with Passion!" group.
> To post to this group, send email to
> java-ee-j2ee-programming-with-passion@googlegroups.com
> To unsubscribe from this group, send email to
> java-ee-j2ee-programming-with-passion+unsubscr...@googlegroups.com<java-ee-j2ee-programming-with-passion%2bunsubscr...@googlegroups.com>
> For more options, visit this group at
>
> http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en?hl=en
>
> To unsubscribe from this group, send email to
> java-ee-j2ee-programming-with-passion+unsubscribegooglegroups.com or reply
> to this email with the words "REMOVE ME" as the subject.
>

-- 
You received this message because you are subscribed to the Google
Groups "Java EE (J2EE) Programming with Passion!" group.
To post to this group, send email to
java-ee-j2ee-programming-with-passion@googlegroups.com
To unsubscribe from this group, send email to
java-ee-j2ee-programming-with-passion+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en?hl=en

To unsubscribe from this group, send email to 
java-ee-j2ee-programming-with-passion+unsubscribegooglegroups.com or reply to 
this email with the words "REMOVE ME" as the subject.

Reply via email to