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...

Explain the life cycle of servlet?

Answer Posted / surajkumar.java

1. 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 web container loads the servlet class and
creates an instance of it and initializes (e.g servlet
context parameters, database connections objects etc) the
servlet instance by calling the init method.
2. Then invokes the service method, passing a request and
response object. The service provided by a servlet is
implemented in the service method of a GenericServlet and
the doMethod methods (where Method can take the value like
Get, Delete, Options, Post, Put, Trace) of an
HttpServlet. Basically a service method extract information
from the request, access external resources, and then
populate the response based on that information.
3. The container calls destroy method to remove servlet
instance. We also do some specialized handling like closing
a connection, freeing the memory used by local variables etc
by explicitly defining the destroy method inside a servlet
class.

Is This Answer Correct ?    14 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What happens when a thread cannot acquire a lock on an object?

1040


what are memory considerations of jsp compares to other web components?

6539


Which containers use a border layout as their default layout?

1144


Explain what is orm?

1114


What is the diffrence between a local-tx-datasource and a xa-datasource? Can you use transactions in both?

1035


what is a portable component?

2017


How a component can be placed on Windows?

2857


Is there a guarantee of uniqueness for entity beans?

1014


What are the design considerations while making a choice between using interface and abstract class?

1100


Name the class that is used to bind the server object with RMI Registry?

2170


What are the pros and cons of detached objects?

990


What are the different class loaders used by jvm?

1099


Do you think that java should have had pointers?

1064


What is the highest-level event class of the event-delegation model?

1104


What are the types of scaling?

1092