The JSP pages
would therefore not produce expected results. Figure 2??“18 shows the result of
invoking ShowInitLoaded1.jsp after rebooting the server but before invoking the
LoadInitServlet.
Figure 2??“18 Result of invoking http://localhost/deployDemo/ShowInitLoaded1.jsp
after rebooting the server but before invoking the LoadInitServlet. The company name
was never loaded into the ServletContext, thus the page shows blank for the name of
the company.
We could easily solve the problem by declaring companyName in context-
param, but then we would have Java code in the JSP pages and we would
have to repeat the check for null everywhere. So, we use load-on-startup to
guarantee that the LoadInitServlet??™s init method is run when the Web application
is first loaded as follows:
LoadInit
coreservlets.LoadInitServlet
companyName
Doozilch Daley Inc.
0
At server startup, the LoadInitServlet will be loaded into memory and its
init method called. If we invoke ShowInitLoad1.jsp as the very first thing at server
reboot, it will now show the name of the company because the LoadInitServlet??™s
init method is guaranteed to have been called.
Chapter 2 ?– Controlling Web Application Behavior with web.
Pages:
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105