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 |
i have class files in class folder. but i have no java files. but i want to modify the java files which are related to class files . how ?
How can we refresh automatically when new data is entered into the database?
Which method the Servlet container call to create the instance of the servlet?
16 Answers emc2, JK Technosoft,
Life Cycle of servlets?
How we can create war file in servlet?
What is servlet and how it works?
How servlets can be automatically reloaded?
How do servlets work?
What is the use of send redirect () method?
Can filter be used as request or response?
Difference between Include, Forward and sendRedirect in Servlet?
Define context initialization parameters.