Chapter 10. Exception Handling
Throwing exceptions is
Java's way of informing dependent clients that
something abnormal occurred during the processing of a method. The
client is notified of the type of problem by an instance of a
specific exception being thrown, and it's entirely
up to the client what course of action to take when an exception
occurs. In some cases, the client may even choose not to take any
action, which causes the JVM to continue to search for a handler for
the exception. Handling exceptions within your Struts applications is not much
different. When an abnormal condition occurs, an exception is thrown
to the calling client to notify it of the abnormality. What is
different for web applications, and specifically the Struts
framework, is what action is taken on behalf of the client and how
these exceptions are reported back to the end user. This chapter looks at how you can properly use the Java
exception-handling mechanism within your Struts applications to help
make your applications more robust and allow them to gracefully
respond when things do not go as expected. Special attention is given
to the differences between performing the exception handling
programmatically and using the new declarative feature added to the
Struts framework in Version 1.1. |