View Javadoc
1   /*
2    * $Id$
3    *
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  package org.apache.struts.chain.commands.servlet;
22  
23  import jakarta.servlet.http.HttpServletRequest;
24  import jakarta.servlet.http.HttpServletResponse;
25  
26  import org.apache.struts.action.ActionForm;
27  import org.apache.struts.action.ActionMapping;
28  import org.apache.struts.chain.commands.AbstractExceptionHandler;
29  import org.apache.struts.chain.commands.util.ClassUtils;
30  import org.apache.struts.chain.contexts.ActionContext;
31  import org.apache.struts.chain.contexts.ServletActionContext;
32  import org.apache.struts.config.ActionConfig;
33  import org.apache.struts.config.ExceptionConfig;
34  import org.apache.struts.config.ForwardConfig;
35  import org.apache.struts.config.ModuleConfig;
36  
37  /**
38   * <p>Handle the specified exception.</p>
39   *
40   * @version $Rev$ $Date: 2005-05-07 12:11:38 -0400 (Sat, 07 May 2005)
41   *          $
42   */
43  public class ExceptionHandler extends AbstractExceptionHandler {
44      // ------------------------------------------------------ Instance Variables
45  
46  
47      // ------------------------------------------------------- Protected Methods
48      protected ForwardConfig handle(ActionContext context, Exception exception,
49          ExceptionConfig exceptionConfig, ActionConfig actionConfig,
50          ModuleConfig moduleConfig)
51          throws Exception {
52          // Look up the remaining properties needed for this handler
53          ServletActionContext sacontext = (ServletActionContext) context;
54          ActionForm actionForm = sacontext.getActionForm();
55          HttpServletRequest request = sacontext.getRequest();
56          HttpServletResponse response = sacontext.getResponse();
57  
58          // Handle this exception
59          org.apache.struts.action.ExceptionHandler handler =
60              (org.apache.struts.action.ExceptionHandler) ClassUtils
61              .getApplicationInstance(exceptionConfig.getHandler());
62  
63          return (handler.execute(exception, exceptionConfig,
64              (ActionMapping) actionConfig, actionForm, request, response));
65      }
66  }