File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes default constructor and init method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "default constructor and init method" Watch "default constructor and init method" New topic
Author

default constructor and init method

Brij Garg
Ranch Hand

Joined: Apr 29, 2008
Posts: 234
container first calls the default constructor and then the init method.

Is it corrent or it is other way around ?

thanks
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

how would it call the init method on an instance before it was created using the constructor?
Brij Garg
Ranch Hand

Joined: Apr 29, 2008
Posts: 234
If i am not wrong you are saying that container calls constructor first and create the instanace and then this instance calls the init method.

Please correct me if i am wrong.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Correct. A servlet is the same as any Java Class: you need to create an instance via a constructor before you can call methods on the instance.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: default constructor and init method
 
Similar Threads
servlet creation-init() or constructor
init() method on servlets
when does a servlet clas get servletness ?
Init() Vs Constructor
Destroy Method in servlet constructor