Explain the life cycle of servlet?
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / sasi kumar
Initialization:A servlet is first loaded and initialized
usually when it is request by the corresponding client.
Service:After initilization,the servlet serve client on
request,implementing the application logic clients of the
web application they belong to.
Destruction:When all pending request are processed and the
servlets have been idle for a specific amount of time,they
may be destroy by the servlet and release all the resources
they occupy.
| Is This Answer Correct ? | 0 Yes | 0 No |
Explain how will the struts know which action class to call when you submit a form?
Can you control when passivation occurs?
What is ioc concept & explain it?
what about static?
If I define a method in JSP scriplet <%..%>, where will it go after translation into a servlet?
Where does the session Object stores? If 100 users are connecting to the server. How does it recognize which session belongs to which user?
5 Answers HCL, Mobillo Venture,
What is the difference between long.class and long.type?
Suppose there are 3 combo box. SELECT COUNTRY SELECT STATE SELECT CITY if i select any country from country conutrylistbox values in the state will get automatically inserted with database values>> THEN on selection of state city will be inserted in city combo box If you can help then please Help me...
Connection Pooling with different type of databases?
how can u cal servlet from java?
What is jboss?
Why DOM Parser would take more Memory than SAX parser while they are parsing?