+91 90691 39140 | +1 253 214 3115 | info@hub4tech.com | hub4tech

Servlet Interview Questions and Answers

1
What is Servlet?

A servlet is a Java technology-based Web component, managed by a container called servlet container or servlet engine, that generates dynamic content and interacts with web clients via a request\/response paradigm.

2
Why is Servlet so popular?

Because servlets are platform-independent Java classes that are compiled to platform-neutral byte code that can be loaded dynamically into and run by a Java technology-enabled Web server.

3
What is the life-cycle of a servlet?
  • Servlet is loaded
  • servlet is instantiated
  • servlet is initialized
  • service the request
  • servlet is destroyed
4
What are the life-cycle methods for a servlet?
Method Description
public void init(ServletConfig config) It is invoked only once when first request comes for the servlet. It is used to initialize the servlet.
public void service(ServletRequest request,ServletResponse)throws ServletException,IOException It is invoked at each request.The service() method is used to service the request.
public void destroy() It is invoked only once when servlet is unloaded.
5
What is servlet container?

The servlet container is a part of a Web server or application server that provides the network services over which requests and responses are sent, decodes MIME-based requests, and formats MIME-based responses. A servlet container also contains and manages servlets through their lifecycle.

Copyright ©2015 Hub4Tech.com, All Rights Reserved. Hub4Tech™ is registered trademark of Hub4tech Portal Services Pvt. Ltd.
All trademarks and logos appearing on this website are the property of their respective owners.
FOLLOW US