You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Wendy Smoak <We...@asu.edu> on 2002/10/30 22:26:09 UTC

LookupDispatchAction "default" value?

I'm using LookupDispatchAction, which uses the 'action' request parameter to
call the appropriate method.

However, when the 'action' parameter is missing from the request, it dies as
expected:
javax.servlet.ServletException: Request[/processContact] does not contain
handler parameter named action

Is there a way to specify a "default" for the parameter it's supposed to
use?

If not, I was thinking of using a Filter to make sure that the request
parameter is present, and to insert it if necessary.  (Seems to me you can't
add request parameters, only attributes, but I haven't tried it yet.)

Have I missed something obvious or do you have any suggestions for handling
this situation?

Also, any advice for custom error pages?  I have a custom page for my own
DAOException class, but these are Error 500's, with different "messages".
Is it possible to have a different error page for "does not contain handler
parameter" vs. other ServletExceptions that also show as code 500?

-- 
Wendy Smoak
http://sourceforge.net/projects/unidbtags 

Re: LookupDispatchAction "default" value?

Posted by Danny Mui <da...@muibros.com>.
I extended the dispatch action to do something like that:

in execute() {

      ActionForward forward = null;
       
        if (mapping.getParameter() == null || 
"".equals(mapping.getParameter())) {
            forward = executeAction(mapping, form, request, response);
        } else {
            forward = 
super.dispatchMethod(mapping,form,request,response, mapping.getParameter());
        }
        return forward;
}

i'm a little weirder, i like to declaratively tell my action which to 
execute.  so extending the if statement to look at the request/form is 
possible.

this may not be lookupdispatchaction but close enough i guess?

well hth

Wendy Smoak wrote:

>I'm using LookupDispatchAction, which uses the 'action' request parameter to
>call the appropriate method.
>
>However, when the 'action' parameter is missing from the request, it dies as
>expected:
>javax.servlet.ServletException: Request[/processContact] does not contain
>handler parameter named action
>
>Is there a way to specify a "default" for the parameter it's supposed to
>use?
>
>If not, I was thinking of using a Filter to make sure that the request
>parameter is present, and to insert it if necessary.  (Seems to me you can't
>add request parameters, only attributes, but I haven't tried it yet.)
>
>Have I missed something obvious or do you have any suggestions for handling
>this situation?
>
>Also, any advice for custom error pages?  I have a custom page for my own
>DAOException class, but these are Error 500's, with different "messages".
>Is it possible to have a different error page for "does not contain handler
>parameter" vs. other ServletExceptions that also show as code 500?
>
>  
>




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>