What is Servlets and explain the advantages of Servlet life cycle?
Answer
Servlets are the programs that run under web server environment. A
copy of Servlet class can handle numerous request threads. In servlets, JVM
stays running and handles each request using a light weight thread.
Servlets life cycle involve three important methods, i.e. init, service and
destroy.
Init()
Init method is called when Servlet first loaded in to the web server memory.
Service()
Once initialized, Servlets stays in memory to process requests. Servlets read
the data provided in the request in the service() method.
Destroy()
When server unloads servlets, destroy() method is called to clean up resources
the servlet is consuming.
More Servlets links
Answer - The Constructor HttpServlet() does nothing because this
is an abstract class.........
Answer - doGet() and doPost() are HTTP requests handled
by servlet classes..........
Answer - Servlet mapping controls how you access a
servlet. It is recommended that you don’t use.........
|