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