Chapter 10. Error Handling
In an ideal world, you would be able to design a JSP-based application, code the pages, and have the system up and running in one single try. In the real world, however, there are many opportunities to make mistakes. Design and coding mistakes will result in errors. This chapter focuses on the different types of errors that you may encounter, and how to handle them using JSP.
The JSP error-handling mechanism is intimately tied to the exception handling mechanism of the Java programming language. This chapter explains this relationship, and also shows how you can use JSP to handle exceptions originating from Java code within the application.
This chapter covers the following topics:
Coding and syntax errors in the Java programming language
JSP coding errors
Logical errors
User data-entry errors
Translation-time errors
Request-time errors
Handling errors using the JSTL
<c:catch>
actionHandling errors using the JSP error page mechanism
Understanding the Origin of Errors
Developers often talk about error handling as if it were a very simple matter, and assume that code can be easily added to handle errors after the completion of a project. This is far from the truth. A usable and robust application relies on an a priori design, and the thought given to the source and handling of possible error conditions.
It is very important to appreciate that there are different sources of error. Each source can also emit errors at different times during the development and deployment ...
Get Beginning JavaServer Pages™ now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.