The JSP Files (part 7): Bugs, Beans And Banks - Bugathon (
Page 2 of 7 )
First,
though, a quick lesson in semantics. There's an important distinction to be
aware of between "errors" and "exceptions".
JSP "errors" cannot usually
be trapped, as they usually involve problems beyond the application developer's
control - things like the server running out of memory, missing files or a
corrupted filesystem.
The term "exceptions", on the other hand, refers to
those errors which can be tracked and controlled. For example, if an argument
provided to a function is incorrect, JSP will "throw" an "invalid argument"
exception, together with a stack trace or detailed explanation of the problem.
Exceptions like these can be "caught" by the application, and appropriately
diverted to an exception-handling routine.
Since JSP shares much in
common with Java, it won't surprise you to learn that JSP's concept of
exceptions is derived almost entirely from Java. In Java, an exception is an
instance of an object; in JSP, an implicit Exception object is available to
identify and manage exceptions.