You can configure a global exception handler, although I'm not 100% sure
it will catch this type of problem.

You can find the documentation online in the usual place, but it basically
amounts to this in struts-config:

  <global-exceptions>
    <exception handler="com.my.company.handlers.GlobalExceptionHandler"
type="java.lang.Exception"
key="key_is_required_by_dtd_but_this_app_does_not_need_it_so_this_is_just_a_dummy_value"
/>
  </global-exceptions>

As the rather long text indicates, key is required, but at least in my
case I have never used it, so I just stick any old value in there.  Come
to think of it, I am not even sure how it is meant to be used!

Beyond that, your exception handler class has to extend ExceptionHandler,
and beyond that it looks very much like an Action with a slightly
different execute() signature:


public ActionForward execute(Exception e, ExceptionConfig config,
                               ActionMapping mapping, ActionForm form,
                               HttpServletRequest request,
                               HttpServletResponse response)
                               throws ServletException

You can do whatever you like, and ultimately return a forward to your
exception page... I suggest getting this particular forward right at least
:) LOL

But again, I'm not certain this type of problem will be caught because I'm
not even sure an exception is thrown in such a case.  If it isn't that
strikes me as a bug.  Anyone else know for sure?

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com

On Mon, June 13, 2005 3:45 pm, Dan Tenenbaum said:
> My codebase has a lot of lines like this in struts actions:
> return mapping.findForward("foo");
>
> If I make a typo and it turns out that "foo" is not a valid forward
> according to the struts config file, when I hit the action in the
> browser, I get a blank page. Not my designated error page.
>
> Is there some sort of struts-centric way to ensure that an exception
> is thrown and my error page appears? I just want to know if there is
> an existing mechanism to do this. I could easily write a method to do
> it (to be called instead of mapping.findForward()) but it seems that
> this is something Struts should handle.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to