| [ directory ] |
Exceptions are an integral part of the Java programming language. When a program violates the rules of Java, the Java Virtual Machine halts execution of the program and generates an exception. Managing exceptions is something every Java program must do. Servlets and JSP are no different. Until now, the topic of programming errors has largely been ignored in favor of introducing JSP and Servlets. While necessary for the start of this book, errors are inevitable and need to be understood so they can be dealt with appropriately. It is the goal of this chapter to clearly explain what exceptions are and how to deal with them in Servlets and JSP.
This chapter discusses the following topics:
A general review of Java's support for exceptions and how Java exception handling works.
How to handle Servlet and JSP exceptions using Java's built-in exception handling mechanism.
How to handle exceptions using the Servlet-specific Web Application Deployment Descriptor called web.xml.
An introduction to the java.util.logging package for appropriately handling information that needs to be recorded, including a focus on logging exception information.
A general philosophy for a Web Application's exception handling and logging.
The preceding points imply this chapter assumes little to nothing about previous knowledge of Java exception handling. This implication is true; the chapter is designed to be suited for both Java developers and "Java" developers who never bothered to truly learn exception handling, who are surprisingly abundant. The chapter is designed to be read straight through, but if you already have a firm grasp on Java exception handling, you may skip the first section and start in on the discussion of Servlet and JSP exception handling.
| [ directory ] |