- Популярные видео
- Авто
- Видео-блоги
- ДТП, аварии
- Для маленьких
- Еда, напитки
- Животные
- Закон и право
- Знаменитости
- Игры
- Искусство
- Комедии
- Красота, мода
- Кулинария, рецепты
- Люди
- Мото
- Музыка
- Мультфильмы
- Наука, технологии
- Новости
- Образование
- Политика
- Праздники
- Приколы
- Природа
- Происшествия
- Путешествия
- Развлечения
- Ржач
- Семья
- Сериалы
- Спорт
- Стиль жизни
- ТВ передачи
- Танцы
- Технологии
- Товары
- Ужасы
- Фильмы
- Шоу-бизнес
- Юмор
71 Understanding flow of execution related to both init method Scenario 3 | Adv java Servlet Tutoria
#adv java #Advance #Java #Servlet #Programming #Tutorial #Understanding #flow of #execution #related to #both #init #method:
- The javax.servlet.GenericServlet class of servlet API contains both init(ServletConfig sc) method , init() method.
Scenario 3:
----------
//GenericServlet.java (Pre-defined java class)
public abstract class GenericServlet implements Servlet
{
ServletConfig config;
public void init(ServletConfig cg)throws ServletException{
//(6)
config=cg; //initialization logic of ServletConfig object
----
init();//
}
public void init()throws ServletException{
//null body method
(7)
}
public ServletConfig getServletConfig(){
----
return config;
}
------
-------//other methods of GenericServlet class
------
}
//Scenario3.java
(1)(2)(3)(4)
//public class Scenario3 extends GenericServlet
//or
public class Scenario3 extends HttpServlet{
public void init(ServletConfig cg)throws ServletException{
//(5)
super.init(cg); //calling super class init(-)
--------//(8)
--------//our servlet program related initialization logic
}
public void service(ServletRequest req,ServletResponse res)throwse ServletException, IOException{
ServletConfig cg=getServletConfig();
---------
//(9)
--------//our servlet program related service logic
}
}
Notes:
1)End user gives first request to our Servlet Program (TestSrv.java) (let us assume no load-on-starupup is enabled on this servlet program)
2) Servlet Container creates our servlet class object using 0-param constructor.
3) Servlet container creates servletConfig object as right hand object for our servlet class object and also it raises instantiation event.
4) To process instantiation event servlet container calls init(servletConfin) life cycle method on our servlet class object having servletconfig object as argument value, Since this init(servletConfig) method is not available in our servlet(TestSrv.java) class, the super class(i.e GenericServlet or HttpServlet) init(ServletConfig ) method will be executed.
5) This super (i.e GenericServlet or HttpServlet) class init(sc) method contains the logic to initialize the ServletConfig Object and also calls init() (with no parameter) method at the end.
6) init() method of our servlet (TestSrv.java) class executes and this completes the initialization process or our servlet program.
7) Servlet container raises request arrival event and it calls public service(-,-) method on our servlet (TestSrv.java) class object. This method execution will process the request and sends the response to browser window.
Notes :
In Scenario 3 Programmer can use getServletConfig() to get access to ServletConfig object to its servlet program.
For this we must call super.init(sconfig) method explicitely without forget/ignorance
Let us see this scenario 3 implementation practically : 24Scenario3
Видео 71 Understanding flow of execution related to both init method Scenario 3 | Adv java Servlet Tutoria канала tech fort
- The javax.servlet.GenericServlet class of servlet API contains both init(ServletConfig sc) method , init() method.
Scenario 3:
----------
//GenericServlet.java (Pre-defined java class)
public abstract class GenericServlet implements Servlet
{
ServletConfig config;
public void init(ServletConfig cg)throws ServletException{
//(6)
config=cg; //initialization logic of ServletConfig object
----
init();//
}
public void init()throws ServletException{
//null body method
(7)
}
public ServletConfig getServletConfig(){
----
return config;
}
------
-------//other methods of GenericServlet class
------
}
//Scenario3.java
(1)(2)(3)(4)
//public class Scenario3 extends GenericServlet
//or
public class Scenario3 extends HttpServlet{
public void init(ServletConfig cg)throws ServletException{
//(5)
super.init(cg); //calling super class init(-)
--------//(8)
--------//our servlet program related initialization logic
}
public void service(ServletRequest req,ServletResponse res)throwse ServletException, IOException{
ServletConfig cg=getServletConfig();
---------
//(9)
--------//our servlet program related service logic
}
}
Notes:
1)End user gives first request to our Servlet Program (TestSrv.java) (let us assume no load-on-starupup is enabled on this servlet program)
2) Servlet Container creates our servlet class object using 0-param constructor.
3) Servlet container creates servletConfig object as right hand object for our servlet class object and also it raises instantiation event.
4) To process instantiation event servlet container calls init(servletConfin) life cycle method on our servlet class object having servletconfig object as argument value, Since this init(servletConfig) method is not available in our servlet(TestSrv.java) class, the super class(i.e GenericServlet or HttpServlet) init(ServletConfig ) method will be executed.
5) This super (i.e GenericServlet or HttpServlet) class init(sc) method contains the logic to initialize the ServletConfig Object and also calls init() (with no parameter) method at the end.
6) init() method of our servlet (TestSrv.java) class executes and this completes the initialization process or our servlet program.
7) Servlet container raises request arrival event and it calls public service(-,-) method on our servlet (TestSrv.java) class object. This method execution will process the request and sends the response to browser window.
Notes :
In Scenario 3 Programmer can use getServletConfig() to get access to ServletConfig object to its servlet program.
For this we must call super.init(sconfig) method explicitely without forget/ignorance
Let us see this scenario 3 implementation practically : 24Scenario3
Видео 71 Understanding flow of execution related to both init method Scenario 3 | Adv java Servlet Tutoria канала tech fort
java tutorial for beginners advanced java advanced java tutorial durgasoft durga sir java tutorial bhosale java telusko java new boston JDBC Servlet jsp java ratan java nptel java saurabh shukla advanced java durga sir advanced java naresh it technology java programming advanced java nataraj advanced java bhosale adv java naveen adv java servlet tutorial edurekha sathya technologies ameerpet hyderabad
Комментарии отсутствуют
Информация о видео
27 февраля 2018 г. 19:53:16
00:20:01
Другие видео канала




















