1)Init and destroy methods are called only once in its lifetime.
2)Service method runs every time you request the servlet.
If you request the LoginServlet with following url 100 times
doGet or doPost method gets called 100 times.
But init method in servlet gets called only one time.
http://localhost:8084/HelloWorld/login.jsp
4)Container prepares ServletConfig object with initalization parameters and passes to init method as argument.
5)You can get ServletContext object from ServletConfig object with following
syntax.
ServletContext context = getServletConfig().getServletContext();
or
directly with following syntax from servlet code.
ServletContext contextDuplicateReference = getServletContext();
6)Once initalization parameters are read.. and loaded in to
ServletConfig object by container,even if you change the initalization
parameter values in web.xml those won't be reflected ,you have to
redeploy the webapplication again.
7)When you request LoginServlet... first container calls service method...
service method in HttpServlet decides whether to call doGet or doPost
based on the method declared in html form.
<form name="hello" method="post">
8)If you don't specify method by default form method is Get.
No comments:
Post a Comment