When the methods init() and Distroy() will be called?
Answers were Sorted based on User's Feedback
The servlet life cycle included init() and destroy()(Small
d).
init() is called at the beginning of the servlet,it
performs certain one time activities which are required
during the lifetime of the servlet.It may be some
initialisation of variables or a database connection.
destroy() is called to destroy the servlet.Various
resources which are held by the servlet will be
released,database connections which were opened will be
closed.Later the servlet is destroyed.
Is This Answer Correct ? | 4 Yes | 0 No |
Answer / abhijitbaji
both init() and destroy() are called only once.
init() at the begining when servlet object is cerated.
destroy() when the servlet object is removed from server(at
shoutdown).
service() is called each time when request comes to servlet.
Is This Answer Correct ? | 2 Yes | 1 No |
What is the difference between the include() and forward() methods?
When the methods init() and Distroy() will be called?
What is difference between GenericServlet and HttpServlet?
Explain the working of service() method of a servlet.
What is lazy loading and what is Generic Servlet Class?
How the JSP file will be executed on the Server side?
What are the features added in Servlet 2.5?
How do cookies work in servlets?
How to get the current httpsession object?
How do you load an image in a Servlet?
How to run a servlet program?
What is the difference between callling a RequestDispatcher using ServletRequest and ServletContext?