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 89 | Next

Larry Brown, Marty Hall, and Yaakov Chaikin

"Core Servlets and JavaServer Pages, Volume 2"

";
private String emailAddress = "Email address is missing";
public void jspInit() {
ServletConfig config = getServletConfig();
if (config.getInitParameter("firstName") != null) {
firstName = config.getInitParameter("firstName");
}
if (config.getInitParameter("emailAddress") != null) {
emailAddress = config.getInitParameter("emailAddress");
}
}
%>
Listing 2.11
web.xml (Excerpt showing init params
for JSP pages)

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">

InitPage
/InitPage.jsp

firstName
Bill

2.6 Initializing and Preloading Servlets and JSP Pages 63
Figure 2??“14 Mapping a JSP page??™s original URL to the registered custom URL pattern
prevents users from accidentally accessing the uninitialized version.
Supplying Application-Wide
Initialization Parameters
Normally, you assign initialization parameters to individual servlets or JSP pages. The
designated servlet or JSP page reads the parameters by means of the getInit-
Parameter method of ServletConfig. However, in some situations you want to
supply system-wide initialization parameters that can be read by any servlet or JSP
page by means of the getInitParameter method of ServletContext.


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