Q) Explain about initialization phase of a servlet?
• Servlet Container calling the init method of the user defined servlet is nothing but its initialization phase.• Initialization also happen's only once in the life time of a servlet.
• During the initialization phase, Servlet Engine does two things.
1.) Creates ServletConfig object
2.) Calls init method by supplying
• ServletConfig object reference as an argument.
• Any resources required for the servlet to attend the client request are provided in init method.
Q) Explain about servicing phase of a servlet?
• Servlet Engine calling the service method of a user-defined servlet is nothing but its servicing phase.• Servlet Engine calls service method for every client request.
• Servlet Container does two things during the servicing phase of a servlet.
1.) Creating ServletRequest object andServletResponse object
2.) Calling service method by supplying ServletRequest object referenceandServletResponse object reference as arguments.
• Within the service method, client request handling code is implemented.
• Within the service method, "request" object is used for capturing the user input and response object is used to create the response page and hand over the same to the web server.
Q) Explain about destruction phase of a servlet?
• Servlet Containercalling the destroy method of a user-defined servlet is nothing but its destruction phase.• When the application is unloaded by the administrator OR the container is shutdown, Servlet Container calls destroy() method of the servlet and releases the reference of the servlet.Then, the servlet instance is garbage collected.
• destroy () method is called only once in the life time of a servlet.
• Any resources allocated to the servlet are released in destroy method. For example closing the PreparedStatement and closing the Connection.
Comments
Post a Comment