struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <craig...@apache.org>
Subject RE: Implementing canProcess method in RequestDispatcher / struts error handling
Date Tue, 09 Jul 2002 16:06:16 GMT


On Tue, 9 Jul 2002 Ken.Horn@ubsw.com wrote:

> Date: Tue, 9 Jul 2002 12:19:51 +0100
> From: Ken.Horn@ubsw.com
> Reply-To: Struts Developers List <struts-dev@jakarta.apache.org>
> To: struts-dev@jakarta.apache.org
> Subject: RE: Implementing canProcess method in RequestDispatcher / struts
>     error handling
>
> As a general point, I'd much rather have most of struts not use
> sendError, rather, just throw an Exception. This makes an app behave
> much more like a standard Java app, where exception propagation can
> occur as per normal and handled in a centralised manner.
>

For the record, Struts 1.1 itself calls sendError() from the following
classes, under the following conditions, with the HTTP status code in
square brackets:

org.apache.struts.action.RequestProcessor:
-----------------------------------------
- [500] Action instance cannot be created (usually a misconfigured
  class name)
- [403] No mapping exists for the specified path, and there is no
  mapping with "unknown='true'"
- [403] Path does not start with subapp prefix (usually a misconfigured
  servlet mapping URL pattern)
- [403] User does not possess one of the roles required for this action
- [500] Validation failed but there is no "input" attribute available
  to redisplay the input form
- [500] Cannot get a RequestDispatcher to forward to a path
- [500] Cannot get a RequestDispatcher to include from a path

org.apache.struts.actions.DispatchAction:
----------------------------------------
- [500] No such method name, or method name not present in request
- [500] ClassCastException on return from invoked method
  (i.e. it doesn't return an ActionForward)
- [500] IllegalAccessException invoking method
- [500] InvocationTargetException invoking method

org.apache.struts.actions.ForwardAction:
---------------------------------------
- [500] No "parameter" configured on this action
- [500] Cannot get request dispatcher to the specified path

org.apache.struts.actions.IncludeAction:
---------------------------------------
- [500] No "parameter" configured on this action
- [500] Cannot get request dispatcher to the specified path

org.apache.struts.actions.SwitchAction:
--------------------------------------
- [403] Neither "page" nor "prefix" request parameters are present
- [403] Cannot select subapp based on the specified request parameters

org.apache.struts.tiles.ActionComponentServlet:
----------------------------------------------
- [500] Validation failed but there is no "input" attribute available
  to redisplay the input form
- [500] Cannot acquire request dispatcher for the specified uri

org.apache.struts.tiles.TilesRequestProcessor:
---------------------------------------------
- [500] Cannot acquire request dispatcher for the specified uri

> Is there a reason for always calling sendError? Shouldn't exceptions be
> handled by the controller?
>

Mostly legacy from 1.0 days, where there wasn't any formal notion of an
exception handler.  Nearly all of the situations above would only happen
as the result of misconfiguration of struts-config.xml or web.xml, and
should be caught during development if your coverage tests are at all
complete.

I'm open to suggestion on how each of the individual cases above should be
handled.  It's important to note, however, that you can also deal with
these situations at the web application level, by using <error-page>
elements in web.xml.

Craig


> -----Original Message-----
> From: Chris Nokleberg [mailto:chris@sixlegs.com]
> Sent: 07 July 2002 17:53
> To: struts-dev@jakarta.apache.org
> Subject: Implementing canProcess method in RequestDispatcher
>
>
> I have a servlet 2.3 filter that needs to forward requests based on whether
> they will be eventually be mapped to an action by struts.
>
> Ideally there would be
>   boolean canProcess(HttpServletRequest, String uri)
> in RequestProcessor, where URI overrides the one in request unless it
> is null.
>
> I do not mind having to subclass RequestProcessor to implement this.
> That would be made much easier, however, if the default implementation
> of processMapping did not call response.sendError when no mapping is
> found. I'd suggest that it just returns null, and the error handling
> code is moved out into the process() method itself.
>
> As it is, I may be able to wrap the response into a dummy object that
> ignores the sendError call, and try to disable the logging of the
> error, but that's quite a hack.
>
> Thanks,
> Chris
>
> --
> To unsubscribe, e-mail:   <mailto:struts-dev-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:struts-dev-help@jakarta.apache.org>
>
>
> Visit our website at http://www.ubswarburg.com
>
> This message contains confidential information and is intended only
> for the individual named.  If you are not the named addressee you
> should not disseminate, distribute or copy this e-mail.  Please
> notify the sender immediately by e-mail if you have received this
> e-mail by mistake and delete this e-mail from your system.
>
> E-mail transmission cannot be guaranteed to be secure or error-free
> as information could be intercepted, corrupted, lost, destroyed,
> arrive late or incomplete, or contain viruses.  The sender therefore
> does not accept liability for any errors or omissions in the contents
> of this message which arise as a result of e-mail transmission.  If
> verification is required please request a hard-copy version.  This
> message is provided for informational purposes and should not be
> construed as a solicitation or offer to buy or sell any securities or
> related financial instruments.
>
>
> --
> To unsubscribe, e-mail:   <mailto:struts-dev-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:struts-dev-help@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <mailto:struts-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-dev-help@jakarta.apache.org>


Mime
View raw message