Hello Atul!

A> I have a basic querry about the architecture of the Servlet as well as for
A> Applet. Why Java has gone for init() in both cases ? as i can do the
A> initilaization in constructor only ? what are the constraints for the
A> constructor coz of which i have to go for init() ?

Well, you tell the servlet container (for servlet) or the browser (for
applet) the name of the class that extends Servlet or Applet class.

It easier for the container just to call

Servlet s = (Servlet)Class.forName(name).newInstance();
s.init(...);

(or a similar code for servlet), then
to use reflection to invoke a constructor
with arguments.

Yes, it is only needed Class.newInstance() method to
create an object by it's Class object if it has a no-arg
constructor, but it is necessary to use reflection to create
an object via a constructor with arguments.

This is my understanding, of course.

Best regards, Anton

___________________________________________________________________________
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