Understanding init, service and ServletConfig
Servlet objects are created in two phases :
1) At the first call
2) Next only threads are created for each request.

There are methods which run before doGet or doPost
init()
service()


init() and init(ServletConfig) and service are part of GenericServlet


service() (overidden from GenericServlet) and doGet ..... are part of HttpServlet


MyServlet will override doGet and doPost .....
we have already seen
Examples :
1) Initparams (Annotation)


2) Using web.xml

Last updated
Was this helpful?