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 |
Can we write a constructor for a Servlet class ? if yes how ? if no why not ?
i need connection pooling code.....from harpreet.your@gmail.com
What is the default http method in the servlet?
init() method of servlet loaded by?
what happens if we wont use destroy()?
Explain the methods in Generic and HTTP Servlets?
what are the CGI Programs?
why we should override only no-agrs init() method.
Once the destroy() method is called by the container, will the servlet be immediately destroyed? What happens to the tasks(threads) that the servlet might be executing at that time?
What are the different ways we can maintain state between requests?
Difference between doget and dopost?
Why are http servlets used in programming?