| Author |
Init() Vs Constructor
|
Niranjan Prasad
Ranch Hand
Joined: Aug 13, 2005
Posts: 62
|
|
|
Constructor is for initialization and so y they introduced init()?
|
 |
Badri Sarma
Ranch Hand
Joined: Apr 01, 2003
Posts: 72
|
|
init method is the life cycle method of servlet and constructor by default it exist if it is a java class. If you look at the API for the following method init(ServletConfig config) it says "Called by the servlet container to indicate to a servlet that the servlet is being placed into service. " Through constructor container cannot place servlet for the service. init is more specific to the container.
|
Thanks<br />Badri
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
This gets asked quite often here. You can either look at our entry in the FAQ: http://faq.javaranch.com/view?ServletsFaq Or search this forum with keywords "constructor" and "init" to find the question asked and answered many times.
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
 |
|
|
subject: Init() Vs Constructor
|
|
|