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

How do I know if java is running on linux?

607


What is preinitialization of a servlet?

584


How would you create deadlock on your servlet?

622


How servlets are deployed in java?

546


What are the steps that are required to handle the multi-threading?

599






What are the uses of servlet

633


What do you mean by default initialization in java servlet?

606


How can we create deadlock situation in servlet?

852


How do cookies work in servlets?

581


What do you mean by deployment descriptor?

555


How does java thread pool work?

548


What do you mean by request dispatcher in servlet?

611


What are the life cycle methods of a servlet?

593


How do you run a servlet?

544


How do we share data using 'getservletcontext ()?

543