Servlet is a Java class-a special java class and it does have a no-argument constructor.
- When the container loads the servlet into the memory, the no-argument constructor is called.(Till now the servlet object is not a servlet but a normal POJO – plain old java object).
- It becomes a servlet when it is given the reference to the servletContext object and servletConfig object.Hence for the no-argument constructor of the servlet it is too early in its life cycle to do initialization.Thus no-argument constructor is used for the instantiation and init() method is used for the initialization.
- Also the constructor is only called once, where as the init and destroy methods are called each time the servlet is put into service or taken out of service, as the servlet container is free to put servlets into service and take them out of service whenever it chooses. So they can be called more than once.
- Also we need a no-argument constructor since it is no use of calling the init method if you haven’t constructed an object to call it on yet.
I and my guys happened to be going through the good tricks found on the blog while immediately got a terrible feeling I
had not expressed respect to the blog owner for those strategies.
The young men came certainly warmed to learn all of them and now have extremely been enjoying them.
We appreciate you turning out to be really accommodating as well as for settling on such fabulous
tips millions of individuals are really wanting to be informed on.
My honest apologies for not expressing appreciation to sooner.
I抎 must verify with you here. Which is not something I normally do! I enjoy studying a post that may make people think. Additionally, thanks for permitting me to comment!
Pingback: TrackBack