> suppose I have a following URL
> /pages/MyDispatchAction.do?nextpage=home
> and class MyDispatchAction has a method
> public ActionForward home(...)
> so this request is handled by this method,
> Suppose there is a request to DispatchAction , for
> which there is no method to handle it , it crashes, 
> Is there a way to forward all these request to a
> default page, if there is no method to handle the
> request???
> Has anyone written or done some thing like this to
> handle this error neatly

I override execute() and provide a default, but my main problem is the
action being called *without* the parameter, not with one that doesn't have
a mapping.

public final class EditContactAction extends LookupDispatchAction
{

   public ActionForward execute( ... )
   {
      if ( request.getParameter( mapping.getParameter() ) == null ) {
         log.debug( "parameter is missing, defaulting to add" );
         return addContact( mapping, form, request, response );
      } else {
         log.debug( "parameter present, calling super.execute" );
         return super.execute( mapping, form, request, response );
      }

   }
}

Sounds like you would need to do something like:
  if ( !getKeyMethodMap.containsKey( request.getParameter(
mapping.getParameter() ) ) { ... }

(But my getKeyMethodMap creates a new Map every time, and I wouldn't want to
do that... perhaps the Map should be a class variable instead.)

Personally I would like to see a 'default' attribute for the <action> tag.
That way LookupDispatchAction could itself fall back on a default value if
the specified parameter is missing or not in the Map.

-- 
Wendy Smoak
Applications Systems Analyst, Sr.
Arizona State University PA Information Resources Management

Reply via email to