This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: default constructor and init method
 
It's not a secret anymore!