Chapter 9. Error Handling and Debugging

When you develop any application that’s more than a trivial example, errors are inevitable. A JSP-based application is no exception. There are many types of errors you will deal with. Simple syntax errors in the JSP pages are almost a given during the development phase. And even after you have fixed all the syntax errors, you may still have to figure out why the application doesn’t work as you intended because of design mistakes. The application must also be designed to deal with problems that can occur when it’s deployed for production use. Users can enter invalid values and try to use the application in ways you never imagined. External systems, such as databases, can fail or become unavailable due to network problems.

Since a web application is the face of the company, making sure it behaves well, even when the users misbehave and the world around it falls apart, is extremely important for a positive customer perception. Proper design and testing is the only way to accomplish this goal.

In this chapter, we look at the types of problems you can expect during development, as well as those common in a production system. We see how you can track down JSP syntax and design errors and how to deal with runtime problems in a graceful manner.

Dealing with Syntax Errors

The first type of error you will encounter is the one you, or your coworkers, create by simple typos; in other words, syntax errors. The JSP container needs every JSP element to be ...

Get JavaServer Pages, Second Edition 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.