You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Dennis <de...@iswsolutions.com> on 2001/02/13 21:11:05 UTC

Proper way to 'forward' dynamically

I haven't been able to find a question regarding this particular
circumstance, so hopefully this isn't in an FAQ somewhere!

In my Action subclass, rather than returning the results of
mapping.findForward(...) I need to forward to a page determined at runtime.
What is the *proper* way to forward to xxx.jsp?  Should I construct an
ActionForward?  (tried that unsuccessfully).


Thanks for any help,

Dennis


Re: Proper way to 'forward' dynamically

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Dennis wrote:

> I haven't been able to find a question regarding this particular
> circumstance, so hopefully this isn't in an FAQ somewhere!
>
> In my Action subclass, rather than returning the results of
> mapping.findForward(...) I need to forward to a page determined at runtime.
> What is the *proper* way to forward to xxx.jsp?  Should I construct an
> ActionForward?  (tried that unsuccessfully).
>

When I need this, I just create a new ActionForward dynamically:

    String path = ... create context-relative path to new page ...
    return (new ActionForward(path));

The path you calculate must be context relative and start with a slash, exactly
like the "path" attributes to your standard <forward> elements.

>
> Thanks for any help,
>
> Dennis

Craig