Handling ExceptionsWhat was happening the last time you used a JSP application and you entered something incorrectly? If the application was well written, it probably threw an exception and displayed an error page. Exceptions that occur while a JSP application is running are called runtime exceptions.
Just as in a Java application, an exception is an object that is an instance of
Errors are different from exceptions. Errors usually indicate linkage or virtual machine problems that your Web application probably won't recover from, such as running out of memory. Exceptions, however, are conditions that can be caught and recovered from. These exceptions might be, for example, a
Runtime exceptions are easy to handle in a JSP application, because they are stored one at a time in the implicit object named
A runtime exception is thrown by the compiled JSP file, the Java class file that contains the translated version of your JSP page. This means that your application has already been compiled and translated correctly. (Exceptions that occur while a file is being compiled or translated are not stored in the This tutorial describes how to create a simple JSP application with several display pages, a JavaBeans component, and one error page that gives informative error messages to the user. In this example, the bean tracks which JSP page the user was working in when the exception was thrown, which gives you, the developer, valuable information so that you can display an informative message. This is a simple error tracking mechanism; we will describe more complex ones later in this book. [Top] [Prev] [Next] [Bottom] Copyright © 2000, Sun Microsystems, Inc. All rights reserved. | ||||||||
|
| ||||||||||||