The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
April 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Here is the answer...

Posted by Vaidehi on June 18, 2001 at 9:53 AM

> > Hello friends,
> > I am having a small doubt, why we need init() method to initialize applets & servlets although we can do the same through constructors.

> > thanx
> > saddy
> I am not a java guru but here's my opinion.
> init() like start() and stop() are standardized methods to help browser know how to initialize, start and stop a applet. This way ease the browser life.

-----------------------------------------------------------------
Well in Jdk 1.0 (for which servlets were written) constructors for dynamically loaded classes couldn't accept arguments. So in order to provide a new servlet any information about itself and its environment, a server had to call a servlet's init() method and pass along an object that implements the ServletConfig interface. Also ServletConfig object is available only in init() method and not in a constructor.




Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us