SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 92 | Next

Larry Brown, Marty Hall, and Yaakov Chaikin

"Core Servlets and JavaServer Pages, Volume 2"

getAttribute("companyName") +
"\n" + "");
}
}
Listing 2.13 ShowInitLoaded1.jsp


Current Company Name

Welcome to ${companyName}!


We changed our name to serve you better!

Listing 2.14 ShowInitLoaded2.jsp


Init Parameter from ServletContext

Init Parameter: ${companyName}



Listing 2.12 LoadInitServlet.java (continued)
Chapter 2 ?–  Controlling Web Application Behavior with web.xml 66
Figure 2??“15 Result of invoking LoadInitServlet with http://localhost/deployDemo/
showLoadInit. The servlet loads a company name using getInitParameter, stores it in
ServletContext, and displays it in the doGet method.
Figure 2??“16 Result of invoking http://localhost/deployDemo/ShowInitLoaded1.jsp.
This page retrieves the name of the company previously stored in the ServletContext
by the LoadInitServlet.
Figure 2??“17 Result of invoking http://localhost/deployDemo/ShowInitLoaded2.jsp.
This page retrieves the name of the company previously stored in the ServletContext
by the LoadInitServlet.
2.6 Initializing and Preloading Servlets and JSP Pages 67
But what happens if we reboot the server and then the JSP pages are accessed before
the LoadInitServlet is invoked? At this point, because the LoadInitServlet has
not yet been loaded into memory, its init method has not been called, and the
attribute companyName is not present in the ServletContext.


Pages:
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104