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

Explain request dispatcher and its methods.

583


What do you mean by httpservlet?

561


How do I support both get and post from the same servlet?

694


What is webservlet?

530


What are the different types of servlets?

513






What is the importance of init() method in Servlet ?

589


What are the features added in Servlet 2.5?

765


How can you push data from an Applet to a Servlet?

605


Explain the custom jsp tags and the beans.

615


How do you find out what client machine is making a request to your servlet

529


Why servlet is used as controller ? Not JSP? I want complete explation?

648


What is meant by Servlet? What are the parameters of service method?

592


What are the new features added to servlet 2.5?

590


Can we override destroy method in servlet?

495


What is the difference between servlet and jsp?

595