You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by cr...@apache.org on 2001/03/13 20:21:43 UTC

cvs commit: jakarta-struts/src/share/org/apache/struts/action ActionServlet.java

craigmcc    01/03/13 11:21:43

  Modified:    src/share/org/apache/struts/action ActionServlet.java
  Log:
  Add debugging messages when ServletContext.getRequestDispatcher() returns
  null, in the remaining cases where this did not occur.  Prevents
  NullPointerException problems on mis-configured struts-config.xml files.
  
  PR: Bugzilla #935
  Submitted by:	Nick Pellow <ni...@svana.org>
  
  Revision  Changes    Path
  1.64      +16 -4     jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java
  
  Index: ActionServlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java,v
  retrieving revision 1.63
  retrieving revision 1.64
  diff -u -r1.63 -r1.64
  --- ActionServlet.java	2001/03/11 02:50:10	1.63
  +++ ActionServlet.java	2001/03/13 19:21:38	1.64
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java,v 1.63 2001/03/11 02:50:10 craigmcc Exp $
  - * $Revision: 1.63 $
  - * $Date: 2001/03/11 02:50:10 $
  + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java,v 1.64 2001/03/13 19:21:38 craigmcc Exp $
  + * $Revision: 1.64 $
  + * $Date: 2001/03/13 19:21:38 $
    *
    * ====================================================================
    *
  @@ -230,7 +230,7 @@
    * </ul>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.63 $ $Date: 2001/03/11 02:50:10 $
  + * @version $Revision: 1.64 $ $Date: 2001/03/13 19:21:38 $
    */
   
   public class ActionServlet
  @@ -1712,6 +1712,12 @@
   	    } else {
   		RequestDispatcher rd =
   		    getServletContext().getRequestDispatcher(path);
  +                if (rd == null) {
  +                    response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
  +                                       internal.getMessage("requestDispatcher",
  +                                                           path));
  +                    return;
  +                }
   		rd.forward(request, response);
   	    }
   	}
  @@ -2044,6 +2050,12 @@
   	    log("  Validation error(s), redirecting to: " + uri);
   	request.setAttribute(Action.ERROR_KEY, errors);
   	RequestDispatcher rd = getServletContext().getRequestDispatcher(uri);
  +        if (rd == null) {
  +            response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
  +                               internal.getMessage("requestDispatcher",
  +                                                   uri));
  +            return (false);
  +        }
   	rd.forward(request, response);
   	return (false);