However, there are times when you might still want to
declare a name for a JSP page. Declaring a name for a JSP page allows you to provide
2.4 Assigning Names and Custom URLs 51
a name to use with customization settings (e.g., initialization parameters and security
settings) and so that you can change the URL that invokes the JSP page (e.g., so that
multiple URLs get handled by the same page or to remove the .jsp extension from the
URL). However, when setting initialization parameters, remember that JSP pages read
initialization parameters by using the jspInit method, not the init method. See
Section 2.6 (Initializing and Preloading Servlets and JSP Pages) for details.
For example, Listing 2.4 is a simple JSP page named TestPage.jsp that just prints
out the local part of the URL used to invoke it. Listing 2.5 shows a portion of the
web.xml file (i.e., deployDemo/WEB-INF/web.xml) used to assign a registered name
of PageName and then to associate that registered name with URLs of the form
http://host/webAppPrefix/UrlTest7/anything. Figure 2??“9 shows the result for the
URL http://localhost/deployDemo/UrlTest7/foo.
Listing 2.4 TestPage.jsp
JSP Test PageTestPage.jsp
URI: <%= request.getRequestURI() %>
Listing 2.5 web.xml (Excerpt illustrating the naming of JSP pages)
Pages:
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89