2

I'm trying to call using action forward property in struts 1 from struts-config, and I would like to invoke another action, which it's located in another struts.config file. And obviously it doesn't work!

My code is:

In "struts-misExpedientes.xml" 
<action path="/s99bIrInicio" forward="$$$WEBROOT_ENVIRONMENT$$$/comunJSP/s99binicio.do">

the other xml file is "struts-comun.xml"
<action path="/s99binicio" forward="/s99bIrWelcomeMensajeDia.do" />

Notes: "WEBROOT_ENVIRONMENT" is a variable I have declared in a property file and its value is [http:// localhost:8100/s99bEnvironmentWar]

I thank any idea you could provided.

Roman C
  • 49,761
  • 33
  • 66
  • 176
David
  • 23
  • 1
  • 7

1 Answers1

2

If you mean that you want to forward from one webapp to another webapp, then this is not possible. Every webapp is isolated from the other webapps. Each has its awn classes, libraries and sessions, different from the other one. So passing HttpRequest objects from one to the other doesn't make sense.

You should probably redirect to the other webapp. BTW, action chaining is discouraged by Struts, even when it's possible, inside a single wepapp.

EDIT: it appears that you're using modules. So do what the documentation says:

There are three approaches for switching from one module to another.

  • You can use the org.apache.struts.actions.SwitchAction from the Extras JAR,
  • you can use a <forward> (global or local) and specify the contextRelative attribute with a value of true,
  • or you can specify the "module" parameter as part of any of the Struts JSP hyperlink tags (Include, Img, Link, Rewrite, or Forward).
Community
  • 1
  • 1
JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255
  • Hi JB, There are both in the same webApp. Concretely in the same WAR module. – David Jan 30 '13 at 16:05
  • There are writen in different struts-config because there are a lot of entries in each module. – David Jan 30 '13 at 16:10
  • 1
    See my edited answer. But forwarding to another action, especially in a separate module, is still bad design. You should probably redirect instead. – JB Nizet Jan 30 '13 at 16:17
  • Thanks! I will try to read what the documentation said about modules. – David Jan 30 '13 at 16:30