Hi it seems that you can use the Struts DispatchAction to do this. Please refer this:
http://www.jguru.com/faq/view.jsp?EID=995474


Paulo Murphy wrote:

Hi again all,

I have a couple of actions with respective forwards that are all working
fine.
Now what I am trying to do is use a single url to redirect to whichever
action, based on a url parameter.

So I added the following to my struts config :

<action path="/redirect" type="com.this.webapp.Redirect" />

Then I created the class Redirect :

public class Redirect {
    public Redirect() {
    }

    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws java.io.IOException,   javax.servlet.ServletException {

        String path = "./" + (String)request.getParameter("path") + ".do";
        if ((path != null) && (path != "")) {
            if (path == "showthis") {
                path += "?parentid=" + (String)request.getParameter
("parentid");
            }
            else if (path == "showthat") {
                path += "?id=" + (String)request.getParameter("id");
            }
        }
        return new ActionForward(path, true);
    }
}

So I would visit http://here.there.com:7874/redirect.do?id=3&path=showthat
and it would be interpreted as :
http://here.there.com:7874/showthat.do?id=3

Can anyone shed some light on the subject. Am I going about this the wrong
way completely?

Thanks in advance for any help

/Paulo Murphy de Freitas


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



Reply via email to