Redirecting directly from action definition

In my struts config file, I have an action def like this

<action path=“/somepage” forward=“”>
<set-property property=“secure” value=“false”/>

Instead of, I want to redirect this link to a totally different domain, say, If it had a forward def, I can put the redirect in it. How do I do it directly, in this case?

Frankly, no clue. But, I’m sure you already know several work around in this.

  1. response.redirect in jsp or action class
  2. javascript

or even fancier solution would be playing w/ servlet. Example, if you have the url

intercept the url and redirect… yeah it’s very manual. Anyways, good luck.

I did try response.redirect, for some reason it isn’t working. I read somewhere that I need to use return; after response.redirect, tried that too, no luck.

Javascript - nope, not a good solution. Plus it’ll be a pain, if I have to pass some other parameters along with the URL string.

If this doesn’t work, I think you should send an e-mail to Sun “You Suck!!!”


So what are you trying to do with the redirect? My guess is you’re trying to record that you are redirecting someone to another site. Is this close?

If you’re doing that you could try to do the following:

Create a very basic Action that all it does is redirect a request to a url that is passed in as a parameter.

public class RedirectAction extends Action
    public ActionForward execute(ActionMapping mapping, ActionForm form, ServletRequest request, ServletResponse response) 
        String url = request.getParameter("url");
        // Log the redirect here...

        ActionForward actionForward = new ActionForward();

        return actionForward;

Then just call the above action when you want to record a external redirect.

<a href="../actions/">Outsite Website</a>

Also, it seems as if you’re using your forwards incorrectly (at least for Struts 1). I don’t think forward is an attribute of action. I thought it was its own separate tag. Here is an example:

<action path="/[I]somepage[/I]" 
        type="[I]the full classpath and name of your class[/I]" >
    <forward name="success" path="" redirect="true" />

I think that should work too.

Best of Luck.