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

Larry Brown, Marty Hall, and Yaakov Chaikin

"Core Servlets and JavaServer Pages, Volume 2"

Still, the world is full of irrational people, and users could supply illegal
parameters, use incorrect URLs, or fail to provide values for required form fields.
Besides, other developers might not be as careful as you are, and they should have
some tools to overcome their deficiencies.
The error-page element is used to handle problems. It has two possible subelements:
error-code and exception-type. The first of these, error-code, designates
what URL to use when a designated Hypertext Transfer Protocol (HTTP) error
code occurs. (If you aren??™t familiar with HTTP error codes, they are discussed in Chapter
6 of Volume I of Core Servlets and JavaServer Pages.) The second of these subelements,
exception-type, designates what URL to use when a designated Java
exception is thrown but not caught. Both error-code and exception-type use
the location element to designate the URL. This URL must begin with /, making
it relative to the Web application root directory. The page at the place designated
by location can access information about the error by looking up two
special-purpose attributes of the HttpServletRequest object: javax.servlet.
error.status_code and javax.servlet.error.message.
2.9 Designating Pages to Handle Errors 73
The error-code Element
To better understand the value of the error-code element, consider what happens
at most sites when you type the file name incorrectly. You typically get a 404 error
message that tells you that the file can??™t be found but provides little useful information.


Pages:
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112