This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes Why Init() method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Reply locked New topic

Why Init() method

Chetan Raju
Ranch Hand

Joined: Aug 02, 2006
Posts: 109
I have a basic question. Why there is a Init method in servlets. Can't we have a constructor do what Init method does ?
Shantanu Puranik
Ranch Hand

Joined: Jun 10, 2004
Posts: 67

This question is already answered HERE.

--- Shantanu
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
servletConfig and servletContext are not available in constructor..

Rahul Bhattacharjee
LinkedIn - Blog
It is sorta covered in the JavaRanch Style Guide.
subject: Why Init() method
Similar Threads
difference b/w init() and init( config)
How does servlet decide which init method to call
init() method doubt?
init missing in servlet
init() vs constructor