Error Pages Property Editor
 |
Note that this feature might not be included in
your version of the IDE. If it is not available, you can edit the deployment
descriptor (web.xml) file using the editor of your choice.
For more information, see Java Servlet 2.3 Specification available
at http://java.sun.com/products/servlet . |
The Error Pages property editor provides a way for you to add, edit, or remove
error pages for the web module. Each entry in the property editor corresponds
to an <error-page>
element in the web module's deployment
descriptor. You can specify that error pages appear either when a Java exception
is thrown or when an HTTP error code is produced.
When a given error occurs in the web application, you can specify that a designated
application resource be used to handle the exception. You can map both HTTP
error codes and Java language exceptions to a specific resource to handle the
error. In this way, the application can generate specialized content, depending
on the error that has occurred.
To display the Error Pages property editor:
- Click the Deployment pane of the web.xml property sheet.
By default, the value field for Error Pages displays No Error Pages.
- Click the value field to make the ellipsis button (...) appear. Then click
the ellipsis button.
To add an error page for HTTP code:
- In the Http Error Code pane, click the Add button. The Add Error Page for
HTTP Code dialog box
appears.
- Type the desired error code in the HTTP Error Code text field. The error
code must be an integer. For instance, type 404.
- Then enter the location in the Error Page Location field. Click the Browse
button to navigate to the desired location using the Browse Resources file
chooser. The error page can be any resource within the web module, such as an HTML page, a JSP
component, or a servlet. The error page can be located in the document base, that is, the web
module top directory, or in any subdirectory of the web module. Typically, it should not be
located in the WEB-INF subdirectory.
- Click OK. The Error Pages property editor displays your error code and
error page location, and the web.xml property sheet indicates the number of
error pages you have specified.
The following output is generated in the deployment descriptor:
<error-page>
   <error-code>404</error-code>
   <location>/myError.jsp</location>
</error-page>
To add an error page for a Java exception:
- In the Java Exception Type pane, click the Add button.
The Add Error Page for Java Exception dialog box
appears.
- Type in the Java exception type, and enter the location of the error page.
Click the Browse button to navigate to the desired location using the Browse
Resources file chooser. The exception type must be a fully qualified class name
of an exception type, a subclass of the java.lang.Exception class.
In other words, the exception type is
any exception that can
by thrown by a class within a JSP. A JSP can use any Java class, so there are
virtually thousands of valid exception types. Commonly used exception types
might include IOException or FileNotFoundException.
- Click OK. The Error Pages property editor displays your exception type and
error page location.
The following output is generated in the deployment descriptor:
<error-page>
   <exception-type>com.myCompany.myException</exception-type>
   <location>/myError.jsp</location>
</error-page>
To edit an error page:
- In the Error Pages property editor, select the desired error page from either
of the two tables, and click the Edit button corresponding to that table.
The appropriate dialog box appears.
- Edit the desired text field. Click OK.
To remove an error page:
- In the Error Pages property editor, select the desired error page from either
of the two tables.
- Click the Remove button corresponding to that table. The specified error
page is deleted.
- Click OK to confirm the action or Cancel to stop the action.
Legal Notices