filmov
tv
62 Enabling load on startup on servlet program from web.xml | Adv Java Servlet Programming Tutorial

Показать описание
Que. #What is the #advantage of #enabling #load-on-startup on #servlet #program? #Advance #Java #Servlet #Programming #Tutorial
Ans: - When load-on-startup is not enabled the first request given to our servlet program will be processed only after our servlet class program object instantiation and initialization done.
- When load-on-startup is enabled on servlet program the first request will be processed directly because servlet container completes servlet instantiation and initialization (means creation of our servlet class object) before the request, either during server startup or during the deployment of web application.
- The amount of response-request time i.e. taken by servlet program to process request and to generate response is called as "response-time of request".
- When load-on-startup is not enabled the response time of first request is 'little bit high' or more, when compared to the response time of other than first request.
- To minimise the first request response time and to equilize with other than first request enable load-on-startup on our servlet program.
- When load-on-startup is NOT enabled on servlet program:
- When load-on-startup is Enabled on servlet program:
Note:
----- Enable load-on-startup only on those servlet program which will be guarentially requested after deploying the web application, like the servlet programs which generates Home Pages, Main menu pages, Login Pages & etc...
- When multiple servlet program of web application are enabled with load-on-startup with different priority values then servlet container performs Pre-Instantiation(*1) of these servlet classes based on their load-on-startup priority values.
- Pre-Instantiation Means (*1 Creating and keeping our servlet-class object ready and initializing these objects either during server startup OR during the deployement of webapplication.)
load-on-startup (Integer Value) /load-on-startup
- High value indicates low-priority.
- Low value indicates high-priority.
- Negative value IGNORES the load-on-startup that is enabled on servlet program i.e. equal to not enabling load-on-startup
load-on-startup -2 /load-on-startup
#From Tomcat 5.5 Version: (Zero is having First priority):
----------------------------
- Here MyServ1, MyServ2, MyServ3, MyServ4 are the servlet program of same webapplication.
load-on-startup value l-o-s value l-o-s value 4l-o-sValue
MyServ1 10 (III) 0(I) 4 (II) 3
MyServ2 5 (II) 1(II) 6 (III) 3
MyServ3 11 (IV) 5(IV) 0 (I) 3
MyServ4 4 (I) 2(III) -1 (Ignore L-O-S) 3
#Before Tomcat 5.5+ Version: (Zero is having least priority):
----------------------------
- Here MyServ1, MyServ2, MyServ3, MyServ4 are the servlet program of same webapplication.
load-on-startup value load-on-startup value
MyServ1 10 (III) 0 (IV)
MyServ2 5 (II) 1 (I)
MyServ3 11 (IV) 5 (III)
MyServ4 4 (I) 2 (II)
Note: Prior to Tomcat 5.5 there is a special meaning for 0(Zero) as load-on-startup priority indicating/last/less priority (At the end of all servlet program).
#Now Let us see/observe the output/proof of above table practically for load-on-startup with java web application:
Step 2) We Need to add Zero param constructor in each servlet program with init(sc) lifecycle method by keeping/placing S.o.p("demo") statement in both (i.e. constructor and init method)
- If load-on-startup enabled on servlet program with no priority then the value for load-on-startup will be taken as 0(Zero) as default priority value.
Ans: - When load-on-startup is not enabled the first request given to our servlet program will be processed only after our servlet class program object instantiation and initialization done.
- When load-on-startup is enabled on servlet program the first request will be processed directly because servlet container completes servlet instantiation and initialization (means creation of our servlet class object) before the request, either during server startup or during the deployment of web application.
- The amount of response-request time i.e. taken by servlet program to process request and to generate response is called as "response-time of request".
- When load-on-startup is not enabled the response time of first request is 'little bit high' or more, when compared to the response time of other than first request.
- To minimise the first request response time and to equilize with other than first request enable load-on-startup on our servlet program.
- When load-on-startup is NOT enabled on servlet program:
- When load-on-startup is Enabled on servlet program:
Note:
----- Enable load-on-startup only on those servlet program which will be guarentially requested after deploying the web application, like the servlet programs which generates Home Pages, Main menu pages, Login Pages & etc...
- When multiple servlet program of web application are enabled with load-on-startup with different priority values then servlet container performs Pre-Instantiation(*1) of these servlet classes based on their load-on-startup priority values.
- Pre-Instantiation Means (*1 Creating and keeping our servlet-class object ready and initializing these objects either during server startup OR during the deployement of webapplication.)
load-on-startup (Integer Value) /load-on-startup
- High value indicates low-priority.
- Low value indicates high-priority.
- Negative value IGNORES the load-on-startup that is enabled on servlet program i.e. equal to not enabling load-on-startup
load-on-startup -2 /load-on-startup
#From Tomcat 5.5 Version: (Zero is having First priority):
----------------------------
- Here MyServ1, MyServ2, MyServ3, MyServ4 are the servlet program of same webapplication.
load-on-startup value l-o-s value l-o-s value 4l-o-sValue
MyServ1 10 (III) 0(I) 4 (II) 3
MyServ2 5 (II) 1(II) 6 (III) 3
MyServ3 11 (IV) 5(IV) 0 (I) 3
MyServ4 4 (I) 2(III) -1 (Ignore L-O-S) 3
#Before Tomcat 5.5+ Version: (Zero is having least priority):
----------------------------
- Here MyServ1, MyServ2, MyServ3, MyServ4 are the servlet program of same webapplication.
load-on-startup value load-on-startup value
MyServ1 10 (III) 0 (IV)
MyServ2 5 (II) 1 (I)
MyServ3 11 (IV) 5 (III)
MyServ4 4 (I) 2 (II)
Note: Prior to Tomcat 5.5 there is a special meaning for 0(Zero) as load-on-startup priority indicating/last/less priority (At the end of all servlet program).
#Now Let us see/observe the output/proof of above table practically for load-on-startup with java web application:
Step 2) We Need to add Zero param constructor in each servlet program with init(sc) lifecycle method by keeping/placing S.o.p("demo") statement in both (i.e. constructor and init method)
- If load-on-startup enabled on servlet program with no priority then the value for load-on-startup will be taken as 0(Zero) as default priority value.