File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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
I agree. Here's the link:
subject: Why Init() method
jQuery in Action, 3rd edition