On the other hand, try typing unknown file names at www.microsoft.com,
www.ibm.com, or www.bea.com. There, you get useful messages that provide alternative
places to look for the page of interest. Providing such useful error pages is a
valuable addition to your Web application. In fact, http://www.plinko.net/404/ has
an entire site devoted to the topic of 404 error pages. This site includes examples of
the best, worst, and funniest 404 pages from around the world.
Listing 2.17 shows the web.xml file that designates Listing 2.18 as the page that
gets displayed when a 404 error code is returned. Listing 2.18 shows the JSP page
that could be returned to clients that provide unknown file names. Figure 2??“19
shows a typical result. Note that the URL displayed in the browser remains the one
supplied by the client; the error page is a behind-the-scenes implementation technique;
the system uses RequestDispatcher.forward to access it, not
response.sendRedirect. Also note the location of NotFound.jsp. Because it is
the server, not the client (e.g., browser), that resolves the path specified by the
location subelement, you are allowed to place NotFound.jsp inside of the WEB-INF
directory.
Listing 2.17 web.xml (Excerpt designating error pages for HTTP error codes)
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://java.
Pages:
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113