Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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

Answers were Sorted based on User's Feedback



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

Answer / ashutosh

Servlet is instantiated by servlet container by calling
method Class.forName(Servlet class name).newInstance();

First of all Servlet Container looks into the
deployment descriptor(web.xml) .It looks the definition of
Servlet.And Than instantiate it by calling
Class.forName(Servlet class name).newInstance();

Is This Answer Correct ?    19 Yes 5 No

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

Answer / suraj kumar

The servlet is controlled by the container in which the servlet has been deployed. When a request is made to a servlet, its mapping is searched in web.xml. If mapping found then the container performs the following steps.
a.If an instance of the servlet does not exist, the Web container loads the servlet class.
b.Creates an instance of the servlet class.
c.Initializes the servlet instance by calling the init method

Is This Answer Correct ?    8 Yes 0 No

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

Answer / ravikiran.chd

no beofre the init() method call the servlet instantiation
happens while the container calls the no-arg constructor of
the servlet

Is This Answer Correct ?    3 Yes 2 No

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

Answer / 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

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

Answer / aruna

servlet is instantiated after the .class file is loaded on
the memory.Then, the instance will be initialized by calling
init()

Is This Answer Correct ?    4 Yes 6 No

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

Answer / harikumar

if we deploy our web root dir in webapps , then we call url
from the browser.
then after loading , it calls the init() method first.
There r two tow init() methods(first init() & second init
()).

Is This Answer Correct ?    2 Yes 9 No

Post New Answer

More Servlets Interview Questions

What exactly is a servlet?

0 Answers  


When servlet is loaded?

0 Answers  


how the HTML data stored in web server?

0 Answers   TCS,


What’s the difference between genericservlet and httpservlet?

0 Answers  


How would you create deadlock on your servlet?

0 Answers  


What is the difference between using getSession(true) and getSession(false) methods?

0 Answers  


Define the life cycle of a servlets.

0 Answers  


What is servlet? Explain

0 Answers  


Explain the features are in servlet 3?

0 Answers  


Why session tracking is needed?

0 Answers  


Difference between forward() method and sendredirect() method ?

0 Answers  


How to create war file?

0 Answers  


Categories