Return-Path: Delivered-To: apmail-jakarta-struts-dev-archive@apache.org Received: (qmail 18520 invoked from network); 9 Jul 2002 16:06:29 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 9 Jul 2002 16:06:29 -0000 Received: (qmail 16222 invoked by uid 97); 9 Jul 2002 16:06:35 -0000 Delivered-To: qmlist-jakarta-archive-struts-dev@jakarta.apache.org Received: (qmail 16165 invoked by uid 97); 9 Jul 2002 16:06:33 -0000 Mailing-List: contact struts-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Struts Developers List" Reply-To: "Struts Developers List" Delivered-To: mailing list struts-dev@jakarta.apache.org Received: (qmail 16115 invoked by uid 98); 9 Jul 2002 16:06:33 -0000 X-Antivirus: nagoya (v4198 created Apr 24 2002) Date: Tue, 9 Jul 2002 09:06:16 -0700 (PDT) From: "Craig R. McClanahan" To: Struts Developers List Subject: RE: Implementing canProcess method in RequestDispatcher / struts error handling In-Reply-To: Message-ID: <20020709084745.T75164-100000@icarus.apache.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Rating: localhost 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N 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 > 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 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: > For additional commands, e-mail: > > > 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: > For additional commands, e-mail: > > -- To unsubscribe, e-mail: For additional commands, e-mail: