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

Larry Brown, Marty Hall, and Yaakov Chaikin

"Core Servlets and JavaServer Pages, Volume 2"

getInitParameter("firstName") from its init
method to get "Larry" and could call getServletConfig().getInit-
Parameter("emailAddress") to get "ellison@microsoft.com".
2.6 Initializing and Preloading Servlets and JSP Pages 57

InitTest
coreservlets.InitServlet

firstName
Larry


emailAddress
ellison@microsoft.com



InitTest
/showInitValues

There are a few common gotchas that are worth keeping in mind when dealing
with initialization parameters:
??? Return values. The return value of getInitParameter is always a
String. So, for integer parameters you might use
Integer.parseInt to obtain an int.
??? Nonexistent values. If the key passed into the getInitParameter
method does not appear inside the servlet??™s init-param
declarations, null will be returned. Because someone other than the
Java developer can modify web.xml, you should always check for null
inside your code.
??? Initialization in JSP. JSP pages use jspInit, not init. JSP pages
also require use of the jsp-file element in place of servlet-class,
as described in Section 2.4 (Assigning Names and Custom URLs).


Pages:
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95