The Servlets are server side java programs, which are used to generate dynamic web content for a web clients. They reside inside a servlet container on a web server or an application server. The servlet container provides them a runtime environment.
If an instance of servlet is non existent then web container loads the servlet class and creates an instance of the servlet.Once the servlet instantiates, web container calls init() method on it to initialize the servlet.This process of initialization can be customized to allow servlet to read persistent configuration data,initialize resources like database connections etc. by overriding init() method of Servlet interface.If initialization of a servelet fails it throws UnavailableException.
Once initialization is done, web container invokes the service method, passing a request and response object depending upon incoming request.
If the container needs to remove the servlet(e.g.when web container is shutting down), it finalizes the servlet by calling the servlet's destroy method.
The javax.servlet.Servlet interface defines the three life-cycle method:-
public void init(ServletConfig config) throws ServletException
public void service( ServletRequest req, ServletResponse res) throws ServletException, IOException
public void destroy()
Servlet interview questions:-
What is a servlet? Explain its lifecycle.
What is the difference between CGI and servlets?
What is a middleware and what is the functionality of Webserver?
Can there be more than one instance of a servlet at one time ?
Why there are no constructors in servlets?
What is a Servlet Context?
What is meant by Session tell me something about HttpSession?
What is the difference between GenericServlet and HTTPServlet?
What is the difference between doGet and doPost methods of HttpServlet class?
Why do GenericServlet and HttpServlet class implement Serializable interface?
If an instance of servlet is non existent then web container loads the servlet class and creates an instance of the servlet.Once the servlet instantiates, web container calls init() method on it to initialize the servlet.This process of initialization can be customized to allow servlet to read persistent configuration data,initialize resources like database connections etc. by overriding init() method of Servlet interface.If initialization of a servelet fails it throws UnavailableException.
Once initialization is done, web container invokes the service method, passing a request and response object depending upon incoming request.
If the container needs to remove the servlet(e.g.when web container is shutting down), it finalizes the servlet by calling the servlet's destroy method.
The javax.servlet.Servlet interface defines the three life-cycle method:-
public void init(ServletConfig config) throws ServletException
public void service( ServletRequest req, ServletResponse res) throws ServletException, IOException
public void destroy()
Servlet interview questions:-
What is a servlet? Explain its lifecycle.
What is the difference between CGI and servlets?
What is a middleware and what is the functionality of Webserver?
Can there be more than one instance of a servlet at one time ?
Why there are no constructors in servlets?
What is a Servlet Context?
What is meant by Session tell me something about HttpSession?
What is the difference between GenericServlet and HTTPServlet?
What is the difference between doGet and doPost methods of HttpServlet class?
Why do GenericServlet and HttpServlet class implement Serializable interface?
No comments:
Post a Comment