O'Reilly logo

Programming Jakarta Struts, Second Edition by Chuck Cavaness

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

Java Exception Handling

Before we dive into how best to handle exceptions in the Struts framework, you should have a picture in your mind of what actually occurs when a method throws an exception. An understanding ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required