File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes when the init() method will be callled 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
Bookmark "when the init() method will be callled" Watch "when the init() method will be callled" New topic

when the init() method will be callled

chandra kunchala

Joined: Aug 06, 2008
Posts: 17
can you tell me when the init() method will be called.

Thanks & Regards
Chandra SCJP5.0
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 41068
The javadocs of Servlet.init(ServletConfig) and GenericServlet.init() combined together answer this question.

Note that a servlet may placed into service either at startup of the web app, or when the first request for that servlet comes in.

Ping & DNS - my free Android networking tools app
Rohith Kumar Singh

Joined: Aug 27, 2008
Posts: 6
init() method of a Servlet is called by the Servlet Container at the time of initializing the servlet. There are two types of initialization possible: pre-initialization (which is done using load-on-startup element of web.xml) and lazy initialization (on demand).

[ August 27, 2008: Message edited by: Bear Bibeault ]
subject: when the init() method will be callled
Similar Threads
Mechanism of init method to initialize servlet
Why is init() needed?
suggestions for a "user selectable database" design
How to find if the servlet is newly created or it was already existing
exception handling