This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes Servlets and the fly likes why do we need init() , when we have constructor? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Reply locked New topic

why do we need init() , when we have constructor?

shivaprasad patla

Joined: Jun 26, 2008
Posts: 7
Hi Guys, I am started studying servlets first time, I have been asked one simple question,

why do we need init() method, when we have servlet constructor to perform initialization things?

My Ans: because we may need to pass objects to initialize,and init() can be overloaded where as servlet constructor can not.
Am I correct? please confirm and provide me some more information if you have.


Cheers.....<br /> <br />shiva<br />SCJP 1.5<br />Preparing for SCWCD
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63042

Please check the Servlets FAQ before posting to see if your question has already been addressed, as this one has.
[ October 16, 2008: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: why do we need init() , when we have constructor?
It's not a secret anymore!