@jpf:catch Annotation

You can use the @jpf:catch annotation to catch exceptions that occur in the page flow and possibly route them to error handlers.

For more information about using this annotation, see Handling Exceptions in Page Flows.

Syntax

@jpf:catch

type = "<exception type>"

{ path = "<path>"  |  method = "<method name>" }

[ message = "<message String>" ]

[ message-key = "<key value>" ]

Attributes

type

Required. Specifies the fully qualified Java type of the exceptions that should be caught.

path

Either this attribute or the method attribute is required. Specifies the resource to which the runtime should forward when it catches an exception of the type specified in the type attribute. The path can map to one of the following:

method

Either this attribute or the path attribute is required. Specifies the name of an exception handler method that has been designated with a @jpf:exception-handler annotation. That method will be invoked when the exception of the type specified in the type attribute is caught.

message

Optional. Specify a string that provides useful information about the exception.  This message will be passed to the exception-handler method, if the method attribute is used.

message-key

Optional. Specify a key that is used to select a message from a message map. Typically this key is used to enable internationalization of messages, which are passed to the exception-handler method, and can also be displayed using the <netui:errors/> tag. The key refers to a message resource that is defined by the @jpf:message-resources Annotation.

Remarks

The following rules apply to this annotation's use:

	/**
	 * Invalid code:
	 * @jpf:exception-handler
	 * @jpf:catch type="Exception" path="foo.jsp" 
	 */
	public Forward bad( Exception e, String msg, String msgKey, ActionForm form ) 	

For information about using the @jpf:catch and @jpf:exception-handler annotations together, to both catch and handle exceptions, see @jpf:exception-handler annotation. Also see Handling Exceptions in Page Flows.

Related Topics

@jpf:exception-handler Annotation

Handling Exceptions in Page Flows

@jpf:action Annotation

@jpf:controller Annotation

@jpf:forward Annotation

@jpf:message-resources Annotation

@jpf:validation-error-forward Annotation

Getting Started with Page Flows