# @jpf:exception-handler Annotation

You can use the @jpf:exception-handler annotation to mark an error handler method that is specified by a @jpf:catch annotation in a page flow. Without a @jpf:exception-handler annotation, the page flow runtime will not route exceptions to an error handler method.

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

## Syntax

@jpf:exception-handler

[ read-only = "{ true | false }" ]

## Attributes

read-only

Optional. The default is read-only="false". Use this attribute to indicate your intention that this method will not update any member data in the page flow. In a WebLogic cluster environment, this designation causes WebLogic Workshop to skip any attempted failover of the pageflow after the action is run. This option may allow you to increase the performance of the page flow in cluster environments, by making it unnecessary for WebLogic Workshop to communicate portions of this page flow's state data across the nodes in the cluster that pertain to the read-only actions.

## Remarks

The following rules apply to this annotation's use:

- The @jpf:exception-handler annotation must be used with a @jpf:catch annotation. For example:

        package login2;

        import com.bea.wlw.netui.pageflow.PageFlowController;
        import com.bea.wlw.netui.pageflow.Forward;
        import com.bea.wlw.netui.pageflow.FormData;
        import javax.servlet.http.HttpServletRequest;
        import javax.security.auth.login.FailedLoginException;

         /**
          * @jpf:controller nested="true"
          */
      	public class Login extends PageFlowController
      	{
      	public String userName;
          /**
           * @jpf:action
           * @jpf:forward name="success" path="LoginSuccess.jsp"
           * @jpf:catch type="FailedLoginException" method="failedLogin"
           */
          protected Forward loginSubmit( LoginForm loginForm )
              throws Exception
          {
              login( loginForm.getUsername(), loginForm.getPassword() );
              userName = loginForm.getUsername();
              return new Forward( "success", loginForm );
          }

          /**
           * @jpf:exception-handler
           * @jpf:forward name="loginPage" path="Login.jsp"
           */
          protected Forward failedLogin( FailedLoginException ex, String actionName,
                                         String message, FormData form )
          {
              LoginForm loginForm = ( LoginForm ) form;
              loginForm.setMessage( "Login incorrect.  Do you need to create an account?" );
              return new Forward( "loginPage" );
          }
      	.
      	.
      	.

- Note that @jpf:catch annotations cannot be used to catch exceptions on exception-handler methods. The following code is invalid and results in a compilation error:

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

Related Topics

@jpf:catch 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