how a servlet is instantiated, whether the container calls
init() or by calling any other method? please somebody reply..

Answer Posted / nishidh soni

Servlet is initialized by two ways...

1)By initializing the constructor:-but in the initial version of JDK 1.0 constructor can not be initialized for the dynamic page loading so that init() method for the servlet comes into the picture.

2)By invoking the init() method:-This init() method is invoked by the servlet container at it is invoked once per servlet and it uses the ServletConfig as a object for the initialized parameter.and the it is like
init(ServletConfig config)
{
.....
}

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is session tracking?

877


What is preinitialization of a servlet?

765


Explain session tracking and its importance?

724


What are the life-cycle methods for a servlet?

715


How would you create deadlock on your servlet?

814


Differentiate between get and post?

872


What's the advantages using servlets than using cgi?

717


why we should override only no-agrs init() method.

859


How is the get () method different from the post() method?

716


Is tomcat a servlet container?

766


What is cgi and what are its drawbacks?

724


What is the difference between Servlet Request and Servlet Context when calling a Request Dispatcher?

813


Why the concept of single thread model interface is used?

718


Can we override servlet service method?

799


What is the default http method in the servlet?

994