Struts and form action

B

Bednarski Adam

Hello
I'm beginner in Strus.
I've got question about "form" tag in Struts.

For example i've got page "Action_1.jsp" wich is called with "Action_1.do":

<html:form action="Action_2.do">
..
..
..
<html:submit>Submit</html:submit>
</html:form>

this page gets data from "Action_1_Form" but also from "Action_2_Form" !

So my question is: why Struts is geting data from "Action_2_Form" ?
In my opinion Struts should get data from "Action_2_Form" after clicking
"Submit" button.

Here is my "struts-config.xml":

<action
path="/Action_1"
type="net.Action_1_form"
scope="request"
<forward name="succes" path="/Action_1.jsp">
</action>
<action
path="/Action_2"
type="net.Action_2_form"
scope="request"
<forward name="succes" path="/Action_2.jsp">
</action>
 
B

Babu Kalakrishnan

Bednarski said:
Hello
I'm beginner in Strus.
I've got question about "form" tag in Struts.

For example i've got page "Action_1.jsp" wich is called with "Action_1.do":

<html:form action="Action_2.do">
.
.
.
<html:submit>Submit</html:submit>
</html:form>

this page gets data from "Action_1_Form" but also from "Action_2_Form" !

So my question is: why Struts is geting data from "Action_2_Form" ?
In my opinion Struts should get data from "Action_2_Form" after clicking
"Submit" button.

Here is my "struts-config.xml":

<action
path="/Action_1"
type="net.Action_1_form"
scope="request"
<forward name="succes" path="/Action_1.jsp">
</action>
<action
path="/Action_2"
type="net.Action_2_form"
scope="request"
<forward name="succes" path="/Action_2.jsp">
</action>

If your config file really looks like this, the question doesn't make
too much of sense, and your class naming is confusing at best.

The "type" attribute of an action specifies the Action class whose
execute method will be invoked when a request comes in with the "path"
specified. So if a request comes in for Action_1.do, I'd expect it to
invoke the execute method in the class "net.Action_1_form" - which must
be a descendant of "Action" - not of "ActionForm".

And the Action_1.jsp would derive no "data" at all from the
Action_2_form class (which again I'd expect to be an Action - not an
ActionForm) - except that when the form is submitted, the execute method
of that class would be asked to process it.

BK
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top