0

Let's say i have a struts-config.xml file, putting action tag only :

</action>
            <action path="/import"
                type="com.app.console.CSVAction"
                    scope="session"
                    name="formName"
                    input="/example.jsp"
                    validate="true">
            <forward name="success" path="/myAction.do?subAction=import"/>
 </action>
  1. What is the role of path attribute, will it call reset method of myAction also.
  2. What if i put redirect parameter to true.

I am asking this question because in my code.. the actionform is getting reset always(where all bean properties will be reset) corresponding to myAction.do, when i call the action myAction.do above.

Please provide the detailed explanation.

Dave Newton
  • 158,873
  • 26
  • 254
  • 302
vermaraj
  • 634
  • 3
  • 10
  • 34

2 Answers2

0
  • The path attribute defines the URL of the action.
  • Why would it call an arbitrarily-named action method?!
  • Oh you mean your action form. reset is always called by the framework, as per the documentation. Reset is almost only for initial checkbox values to work around how HTTP/clients handle unchecked checkboxes.
  • It will redirect to the forward.

Please consider reading some Struts 1 documentation.

Dave Newton
  • 158,873
  • 26
  • 254
  • 302
  • .i have read the documentation of Struts1. But still in confusion .. the Statemnt : **Reset is almost only for initial checkbox values.** Is this related to -> tags – vermaraj May 28 '14 at 13:28
  • Why it redirect? It forwards. Why struts1 doesn't have redirect tag? – Roman C May 28 '14 at 14:04
  • @RomanC The "redirect" attribute in forward elements... redirects, e.g., http://stackoverflow.com/questions/9885967/redirect-or-forward or as described in the docs. OP asked what if redirect is used, that's what it'll do: redirect. Why? Ask the original devs. – Dave Newton May 28 '14 at 14:32
  • If you do redirect, it's right way. Who is original dev? Anyway moving to S2 is a right way. Forward is not a redirect, even in servlet terms. If the framework is based on configuration (flow) it should provide the user freedom to provide the flow their way end user want with an ability to describe a domain in terms suitable in their domain. – Roman C May 28 '14 at 16:48
  • @RomanC If you want to redirect using the Struts 1 XML configuration you set the "redirect" attribute in the `` element. That's how the framework works, and how it worked from S1.1-S1.3. That *does* provide the ability for the dev to decide whether to forward or redirect without resorting to low-level HTTP or JS, and it does so in the domain of the S1 configuration, which is the point of the S1 configuration. Ted Husted was the original S1 developer, although I don't know if he created the well-documented "redirect" attribute. – Dave Newton May 28 '14 at 17:15
0

If you specify redirect="true", Struts uses a client-side redirect [

response.sendRedirect()].

The JSP will be invoked by a new browser request, and any data stored in the old request will be lost.

Mohit Singh
  • 5,977
  • 2
  • 24
  • 25