This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Struts and the fly likes dispatch and redirect-action Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "dispatch and redirect-action" Watch "dispatch and redirect-action" New topic
Author

dispatch and redirect-action

FY Hsieh
Ranch Hand

Joined: Aug 07, 2006
Posts: 73
I use

**********************

<action name="viewOrder" class=".." ..>
<result name="success" type="dispatch">getOrder</result>
</action>

<action name="getOrder" class=".." ..>
<result name="success">/jsp/getOrder.jsp</result>
</action>
**********************

It works fine with http://../viewOrder?custId=..

But it fails when I use

*************************
<action name="viewOrder" class=".." ..>
<result name="success" type="redirect-dispatch">getOrder</result>
</action>

<action name="getOrder" class=".." ..>
<result name="success">/jsp/getOrder.jsp</result>
</action>
******************************

it shows me action "getOrder is not mapped this time.

Don't know what mistake I made.


FY Hsieh
Ranch Hand

Joined: Aug 07, 2006
Posts: 73
correct -- when I used

type="chain"

it worked, and when I used

type="redirect-action"

it failed.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Please UseCodeTags when posting code or configuration. Unformatted code and configuration is very difficult to read. You can edit your post to include them by using the button.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

What is the *exact* error message you're getting? What's the stack trace? Have you checked your configuration using the config-browser plugin?
FY Hsieh
Ranch Hand

Joined: Aug 07, 2006
Posts: 73
David Newton wrote:What is the *exact* error message you're getting? What's the stack trace? Have you checked your configuration using the config-browser plugin?


The error message is always the same ---

org.apache.struts2.dispatcher.Dispatcher serviceAction Could not find action or result
There is no Action mapped for action name xxxx

where "xxxx" is the action I want to use redirect-action to redirect to

I have already defined the action and it should be fine because if I call that action "xxxx" directly it works fine.

Another thing is --- if I change the type to "redirect" and use the FULL path in <result type="redirect"> http://localhost:80/app/xxx.action </result> it works. But whenver I change the full path to the action name itself it always shows me "There is no Action mapped for the action.."
jaisai vijay
Ranch Hand

Joined: Dec 17, 2009
Posts: 70
As per my understanding

YOu trying to call action class which extends DispatchAction.

I am new to struts I was doing doing like

I have a hidden variable like
in Struts config file you need to provide parameter="do" in the corresponding action.

or you can call the javascript function to submit action like



thats all you need to do. It works for me let me know.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

@Jaisai Vijay: Wrong version of Struts.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

What version of Struts 2 are you using? Are there any errors in the log on startup? I ask because as of Struts 2.1 the correct result type is "redirectAction" (not "redirect-action").
jaisai vijay
Ranch Hand

Joined: Dec 17, 2009
Posts: 70
Hello David,

I am using Struts1.2 anyway I don't see any errors it perfectly works for me. If FY Hsieh is using different version I am sorry for that.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

jaisai vijay wrote:I am using Struts1.2 anyway I don't see any errors it perfectly works for me. If FY Hsieh is using different version I am sorry for that.

I was asking the original poster for the Struts version--by looking at the configuration supplied by the original poster it's clear that you and he are using completely different versions.
FY Hsieh
Ranch Hand

Joined: Aug 07, 2006
Posts: 73
I am using struts 2. Actually I have tried both "redirectAction" and "redirect-action" They gave me the same error
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Have you checked your configuration using the config-browser plugin?

Have you turned logging up to DEBUG level and checked the logs on startup for errors?
 
Consider Paul's rocket mass heater.
 
subject: dispatch and redirect-action