emilly
emilly

Reputation: 10530

Forward the request to non struts 2 action from struts2 action?

I have legacy appication which is using proprieatary framework which is more or less like struts 1.2.Now we have started using struts 2. At lot of places i am submitting the html form to old actions from jsp. What i want is first request goes to my new struts 2 action and then i forward the request to my legacy action from there so that i get all source request paramters in destination legacy action.I know there is result type redirect(as mentioned below) but that wont forward the source request paramters to legacy action.

@Result(name = "displayCustomer",
        location = "legacyAction.do", type = "redirect")


@Action("display-customer!displayCustomer")
  public String displayCustomer() {
    return "displayCustomer";
  }

I did not find any type as "forward" similar to redirect. I am not sure how to forward the request to non struts 2 action from struts 2 action?

Upvotes: 1

Views: 1764

Answers (2)

arvin_codeHunk
arvin_codeHunk

Reputation: 2390

you can simply forward the control to respective page based on your result type for example SUCCESS.You can use chain result type for executing two different action at one time.

It will look like this:

using XML configuration

    <action class="your_action_path" name="your_action_name" method="your_target_method">
                <result type="chain">your_legacy_action</result>
    </action>

     //Then your_legacy_action_mapping here

<action class="your_legacy_action_path" name="your_legacy_action_name" method="your_target_method">
                <result>your_target_success_page</result>
    </action>

Upvotes: 1

Dev Blanked
Dev Blanked

Reputation: 8865

in struts2 default result type is configured as 'dispatcher'. which 'forwards' the request. try setting the type="dispatcher". Check your struts configuration whether 'dispatcher' result type has been configured properly. It should look like something below.

<result-types>
   <result-type name="dispatcher" default="true"
                class="org.apache.struts2.dispatcher.ServletDispatcherResult" />
</result-types>

Upvotes: 0

Related Questions