You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Dom Incollingo <Do...@austin.rr.com> on 2005/04/03 00:34:32 UTC
Form Submitted Twice
Hello,
I'm using Struts 1.2.4 (along with the validator framework), and I've
noticed that for my forms that do a Post, the action class is executed
twice. I put log statements in my Action class, in the validator
classes, in the Struts ActionServlet, and in the JSP to try to figure
out what is happening. The sequence of events is as follows:
- User presses Update button on a JSP
- doPost method invoked (ActionServlet)
- Struts validation methods invoked
- execute method (Action class) entered
- execute method (Action class) returns forward action of Success
- processing returns to the same JSP
.........................................................................
- doGet method invoked (ActionServlet)
- Struts validation methods invoked
- execute method (Action class) entered
- processing returns to the same JSP
- web page is displayed on browser
Everything prior to the doGet looks normal. I can't understand why the
JSP submits a Get request when it should display. The method specified
in the JSP's form (there is only one form in the JSP) is a Post, not a
Get. The JSP does not contain any form submission via JavaScript.
I also notice that if I change the method in the JSP's form from Post to
Get, this problem goes away: the form is submitted only once!
In a related problem, I have a JSP that does have a form with a method
of Get, but the user never clicks on a button to submit the form.
Instead, the user clicks on a link with a value like:
http://localhost:8080/pets/action/petDetail?userAction=Display&type=Pet&id=2.
I expect processing to go to the Action class associated with
'petDetail'. Processing does go there, but first a 'doGet' is processed
in the ActionServlet, even though a form was not submitted.
Has anyone seen these problems or know what is happening here? Thanks
very much for your assistance.
Dom
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Form Submitted Twice
Posted by Dom Incollingo <Do...@austin.rr.com>.
Martin,
I override the validate method in my ActionForm, but the overriding
method did nothing but return the result of a call to super.validate().
This didn't seem to make any difference.
Then I made a functional change (for an unrelated problem). There were
a couple work fields stored in the form bean (ActionForm), called
userAction and systemAction, that were being used to determine which
buttons to display based on what the user was trying to do. I removed
the field called systemAction..... And when I ran the next test, the
system did a doPost but did not follow that with a doGet. I can't begin
to imagine how this could have solved the problem.... I'm quite
confused, but this one page seems to be working correctly now.
There is one more page that does a doPost and then a doGet before the
next page is displayed. However, the action class for that page is
forwarding control to another action class rather than to a JSP. So I
suspect that doPost / doGet is correct. (Or else there is a different
problem there.)
At any rate, thanks very much for your help.
Dom
Martin Gainty wrote:
> Personally yes I would advise override the validate method Here is the
> relevant doc
> http://struts.apache.org/api/org/apache/struts/action/ActionForm.html
> (most notably implementing Serializable) with the end result
> to display the ActionError message /*and ultimately */..
> process the message returned by ActionError
> Keep in mind if your validate method returns null you will pass to
> Action.execute
> HTH,
> Martin-
> ----- Original Message -----
> From: "Dom Incollingo" <Do...@austin.rr.com>
> To: "Struts Users Mailing List" <us...@struts.apache.org>
> Sent: Sunday, April 03, 2005 7:30 PM
> Subject: Re: Form Submitted Twice
>
>
>
>>Martin,
>>
>>My ActionForm subclasses the struts ValidatorForm class. But it does
>>not override the validate method. It just uses whatever validate method
>>it inherits. I checked the source code for the version of ValidatorForm
>>I am using (the one that came with Struts 1.2.4), and it returns an
>>ActionErrors object.
>>
>>Does the validate method need to be overridden in the ActionForm
>>subclass? Thanks.
>>
>>Dom
>>
>>Martin Gainty wrote:
>>
>>>Dom-
>>>This depends on the return of your ActionForm validate method
>>>If you can show us the code and I'll take a look at it tonite
>>>Thanks,
>>>Martin-
>>>----- Original Message -----
>>>From: "Dom Incollingo" <Do...@austin.rr.com>
>>>To: "Struts Users Mailing List" <us...@struts.apache.org>
>>>Sent: Sunday, April 03, 2005 4:25 PM
>>>Subject: Re: Form Submitted Twice
>>>
>>>
>>>
>>>
>>>>Martin,
>>>>
>>>>Thanks very much for the info.
>>>>
>>>>I've tried to follow this pattern, both in the servlet-mapping in the
>>>>web.xml:
>>>>
>>>>
>>>> <servlet-mapping>
>>>> <servlet-name>pets</servlet-name>
>>>> <url-pattern>/action/*</url-pattern>
>>>> </servlet-mapping>
>>>>
>>>>and in the action element in the struts-config:
>>>>
>>>> <action
>>>> path="/petDetail"
>>>> type="com.dom.struts.pets.action.PetDetailAction"
>>>> scope="request"
>>>> name="petDetailForm"
>>>> validate="true"
>>>> input="/petDetail.jsp">
>>>> <forward name="OwnerList" path="/action/getOwnerList"/>
>>>> <forward name="OwnerDetail" path="/action/ownerDetail"/>
>>>> <forward name="PetList" path="/action/getPetList"/>
>>>> <forward name="Success" path="/petDetail.jsp"/>
>>>> <forward name="Failure" path="/petDetail.jsp"/>
>>>> <forward name="Logoff" path="/action/logout"/>
>>>> </action>
>>>>
>>>>Evidently, something is not set up correctly, but it's not obvious to me
>>>>where the problem lies. I'm trying to step thru debug (using Eclipse
>>>>with Tomcat) to see if I can figure out what struts is having a problem
>>>>with.
>>>>
>>>>Thanks.
>>>>
>>>>Dom
>>>>
>>>>
>>>>Martin Gainty wrote:
>>>>
>>>>
>>>>>Dom
>>>>>Apparently the action tag was not setup properly to ensure validation
>>>
>>>before
>>>
>>>
>>>>>posting to RequestProcessor
>>>>>To quote James Goodwill and Rick Hightower
>>>>>For the purposes of simplicity, our sample legacy Web resource will be
>
> a
>
>>>>>servlet. Essentially, you want the servlet's doGet method to be called
>>>
>>>only
>>>
>>>
>>>>>if the ActionForm validates
>>>>>e.g.
>>>>> <servlet-mapping>
>>>>> <servlet-name>legacy</servlet-name>
>>>>> <url-pattern>/legacy/roar</url-pattern>
>>>>> </servlet-mapping>
>>>>>
>>>>>Thus, posts to /legacy/roar would cause this servlet's doPost method to
>>>
>>>be
>>>
>>>
>>>>>called. Now, to map this servlet as an action that acts as a form
>>>
>>>handler,
>>>
>>>
>>>>>you need to do this:
>>>>>
>>>>> <action
>>>>> path="/legacy"
>>>>> forward="/legacy/roar"
>>>>> input="/form/userForm.jsp"
>>>>> name="userForm"
>>>>> parameter="/legacy/roar"
>>>>> validate="true"
>>>>> scope="request"
>>>>> />
>>>>>thus
>>>>>validate attribute is set to true in the action mapping for this
>>>
>>>servlet, so
>>>
>>>
>>>>>the execute method of the ForwardAction is called ONLY if the
>
> ActionForm
>
>>>>>(UserForm) validates (returns no ActionError objects).
>>>>>
>>>>>Makes sense?
>>>>>Martin-
>>>>>
>>>>>----- Original Message -----
>>>>>From: "Dom Incollingo" <Do...@austin.rr.com>
>>>>>To: "Struts User" <us...@struts.apache.org>
>>>>>Sent: Saturday, April 02, 2005 6:34 PM
>>>>>Subject: Form Submitted Twice
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>>Hello,
>>>>>>
>>>>>>I'm using Struts 1.2.4 (along with the validator framework), and I've
>>>>>>noticed that for my forms that do a Post, the action class is executed
>>>>>>twice. I put log statements in my Action class, in the validator
>>>>>>classes, in the Struts ActionServlet, and in the JSP to try to figure
>>>>>>out what is happening. The sequence of events is as follows:
>>>>>>
>>>>>>- User presses Update button on a JSP
>>>>>>- doPost method invoked (ActionServlet)
>>>>>>- Struts validation methods invoked
>>>>>>- execute method (Action class) entered
>>>>>>- execute method (Action class) returns forward action of Success
>>>>>>- processing returns to the same JSP
>>>>
>>>>.........................................................................
>>>>
>>>>>>- doGet method invoked (ActionServlet)
>>>>>>- Struts validation methods invoked
>>>>>>- execute method (Action class) entered
>>>>>>- processing returns to the same JSP
>>>>>>- web page is displayed on browser
>>>>>>
>>>>>>Everything prior to the doGet looks normal. I can't understand why
>
> the
>
>>>>>>JSP submits a Get request when it should display. The method
>
> specified
>
>>>>>>in the JSP's form (there is only one form in the JSP) is a Post, not a
>>>>>>Get. The JSP does not contain any form submission via JavaScript.
>>>>>>
>>>>>>I also notice that if I change the method in the JSP's form from Post
>
> to
>
>>>>>>Get, this problem goes away: the form is submitted only once!
>>>>>>
>>>>>>In a related problem, I have a JSP that does have a form with a method
>>>>>>of Get, but the user never clicks on a button to submit the form.
>>>>>>Instead, the user clicks on a link with a value like:
>>>>>>
>>>>>
>>>>>
> http://localhost:8080/pets/action/petDetail?userAction=Display&type=Pet&id=2
>
>>>>>>I expect processing to go to the Action class associated with
>>>>>>'petDetail'. Processing does go there, but first a 'doGet' is
>
> processed
>
>>>>>>in the ActionServlet, even though a form was not submitted.
>>>>>>
>>>>>>Has anyone seen these problems or know what is happening here?
>
> Thanks
>
>>>>>>very much for your assistance.
>>>>>>
>>>>>>Dom
>>>>>>
>>>>>>---------------------------------------------------------------------
>>>>>>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>>>>For additional commands, e-mail: user-help@struts.apache.org
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>---------------------------------------------------------------------
>>>>>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>>>For additional commands, e-mail: user-help@struts.apache.org
>>>>>
>>>>
>>>>--
>>>>Linux is like a teepee: no Windows, no Gates, Apache inside.
>>>>
>>>>---------------------------------------------------------------------
>>>>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>>For additional commands, e-mail: user-help@struts.apache.org
>>>>
>>>>
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>For additional commands, e-mail: user-help@struts.apache.org
>>>
>>
>>--
>>Linux is like a teepee: no Windows, no Gates, Apache inside.
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
--
Linux is like a teepee: no Windows, no Gates, Apache inside.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Form Submitted Twice
Posted by Martin Gainty <mg...@hotmail.com>.
Personally yes I would advise override the validate method Here is the
relevant doc
http://struts.apache.org/api/org/apache/struts/action/ActionForm.html
(most notably implementing Serializable) with the end result
to display the ActionError message /*and ultimately */..
process the message returned by ActionError
Keep in mind if your validate method returns null you will pass to
Action.execute
HTH,
Martin-
----- Original Message -----
From: "Dom Incollingo" <Do...@austin.rr.com>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Sunday, April 03, 2005 7:30 PM
Subject: Re: Form Submitted Twice
> Martin,
>
> My ActionForm subclasses the struts ValidatorForm class. But it does
> not override the validate method. It just uses whatever validate method
> it inherits. I checked the source code for the version of ValidatorForm
> I am using (the one that came with Struts 1.2.4), and it returns an
> ActionErrors object.
>
> Does the validate method need to be overridden in the ActionForm
> subclass? Thanks.
>
> Dom
>
> Martin Gainty wrote:
> > Dom-
> > This depends on the return of your ActionForm validate method
> > If you can show us the code and I'll take a look at it tonite
> > Thanks,
> > Martin-
> > ----- Original Message -----
> > From: "Dom Incollingo" <Do...@austin.rr.com>
> > To: "Struts Users Mailing List" <us...@struts.apache.org>
> > Sent: Sunday, April 03, 2005 4:25 PM
> > Subject: Re: Form Submitted Twice
> >
> >
> >
> >>Martin,
> >>
> >>Thanks very much for the info.
> >>
> >>I've tried to follow this pattern, both in the servlet-mapping in the
> >>web.xml:
> >>
> >>
> >> <servlet-mapping>
> >> <servlet-name>pets</servlet-name>
> >> <url-pattern>/action/*</url-pattern>
> >> </servlet-mapping>
> >>
> >>and in the action element in the struts-config:
> >>
> >> <action
> >> path="/petDetail"
> >> type="com.dom.struts.pets.action.PetDetailAction"
> >> scope="request"
> >> name="petDetailForm"
> >> validate="true"
> >> input="/petDetail.jsp">
> >> <forward name="OwnerList" path="/action/getOwnerList"/>
> >> <forward name="OwnerDetail" path="/action/ownerDetail"/>
> >> <forward name="PetList" path="/action/getPetList"/>
> >> <forward name="Success" path="/petDetail.jsp"/>
> >> <forward name="Failure" path="/petDetail.jsp"/>
> >> <forward name="Logoff" path="/action/logout"/>
> >> </action>
> >>
> >>Evidently, something is not set up correctly, but it's not obvious to me
> >>where the problem lies. I'm trying to step thru debug (using Eclipse
> >>with Tomcat) to see if I can figure out what struts is having a problem
> >>with.
> >>
> >>Thanks.
> >>
> >>Dom
> >>
> >>
> >>Martin Gainty wrote:
> >>
> >>>Dom
> >>>Apparently the action tag was not setup properly to ensure validation
> >
> > before
> >
> >>>posting to RequestProcessor
> >>>To quote James Goodwill and Rick Hightower
> >>>For the purposes of simplicity, our sample legacy Web resource will be
a
> >>>servlet. Essentially, you want the servlet's doGet method to be called
> >
> > only
> >
> >>>if the ActionForm validates
> >>>e.g.
> >>> <servlet-mapping>
> >>> <servlet-name>legacy</servlet-name>
> >>> <url-pattern>/legacy/roar</url-pattern>
> >>> </servlet-mapping>
> >>>
> >>>Thus, posts to /legacy/roar would cause this servlet's doPost method to
> >
> > be
> >
> >>>called. Now, to map this servlet as an action that acts as a form
> >
> > handler,
> >
> >>>you need to do this:
> >>>
> >>> <action
> >>> path="/legacy"
> >>> forward="/legacy/roar"
> >>> input="/form/userForm.jsp"
> >>> name="userForm"
> >>> parameter="/legacy/roar"
> >>> validate="true"
> >>> scope="request"
> >>> />
> >>>thus
> >>>validate attribute is set to true in the action mapping for this
> >
> > servlet, so
> >
> >>>the execute method of the ForwardAction is called ONLY if the
ActionForm
> >>>(UserForm) validates (returns no ActionError objects).
> >>>
> >>>Makes sense?
> >>>Martin-
> >>>
> >>>----- Original Message -----
> >>>From: "Dom Incollingo" <Do...@austin.rr.com>
> >>>To: "Struts User" <us...@struts.apache.org>
> >>>Sent: Saturday, April 02, 2005 6:34 PM
> >>>Subject: Form Submitted Twice
> >>>
> >>>
> >>>
> >>>
> >>>>Hello,
> >>>>
> >>>>I'm using Struts 1.2.4 (along with the validator framework), and I've
> >>>>noticed that for my forms that do a Post, the action class is executed
> >>>>twice. I put log statements in my Action class, in the validator
> >>>>classes, in the Struts ActionServlet, and in the JSP to try to figure
> >>>>out what is happening. The sequence of events is as follows:
> >>>>
> >>>>- User presses Update button on a JSP
> >>>>- doPost method invoked (ActionServlet)
> >>>>- Struts validation methods invoked
> >>>>- execute method (Action class) entered
> >>>>- execute method (Action class) returns forward action of Success
> >>>>- processing returns to the same JSP
> >>
>
>>>.........................................................................
> >>>
> >>>>- doGet method invoked (ActionServlet)
> >>>>- Struts validation methods invoked
> >>>>- execute method (Action class) entered
> >>>>- processing returns to the same JSP
> >>>>- web page is displayed on browser
> >>>>
> >>>>Everything prior to the doGet looks normal. I can't understand why
the
> >>>>JSP submits a Get request when it should display. The method
specified
> >>>>in the JSP's form (there is only one form in the JSP) is a Post, not a
> >>>>Get. The JSP does not contain any form submission via JavaScript.
> >>>>
> >>>>I also notice that if I change the method in the JSP's form from Post
to
> >>>>Get, this problem goes away: the form is submitted only once!
> >>>>
> >>>>In a related problem, I have a JSP that does have a form with a method
> >>>>of Get, but the user never clicks on a button to submit the form.
> >>>>Instead, the user clicks on a link with a value like:
> >>>>
> >>>
> >>>
> >
http://localhost:8080/pets/action/petDetail?userAction=Display&type=Pet&id=2
> >
> >>>
> >>>> I expect processing to go to the Action class associated with
> >>>>'petDetail'. Processing does go there, but first a 'doGet' is
processed
> >>>>in the ActionServlet, even though a form was not submitted.
> >>>>
> >>>>Has anyone seen these problems or know what is happening here?
Thanks
> >>>>very much for your assistance.
> >>>>
> >>>>Dom
> >>>>
> >>>>---------------------------------------------------------------------
> >>>>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >>>>For additional commands, e-mail: user-help@struts.apache.org
> >>>>
> >>>>
> >>>
> >>>
> >>>---------------------------------------------------------------------
> >>>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >>>For additional commands, e-mail: user-help@struts.apache.org
> >>>
> >>
> >>--
> >>Linux is like a teepee: no Windows, no Gates, Apache inside.
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >>For additional commands, e-mail: user-help@struts.apache.org
> >>
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
>
> --
> Linux is like a teepee: no Windows, no Gates, Apache inside.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Form Submitted Twice
Posted by Dom Incollingo <Do...@austin.rr.com>.
Martin,
My ActionForm subclasses the struts ValidatorForm class. But it does
not override the validate method. It just uses whatever validate method
it inherits. I checked the source code for the version of ValidatorForm
I am using (the one that came with Struts 1.2.4), and it returns an
ActionErrors object.
Does the validate method need to be overridden in the ActionForm
subclass? Thanks.
Dom
Martin Gainty wrote:
> Dom-
> This depends on the return of your ActionForm validate method
> If you can show us the code and I'll take a look at it tonite
> Thanks,
> Martin-
> ----- Original Message -----
> From: "Dom Incollingo" <Do...@austin.rr.com>
> To: "Struts Users Mailing List" <us...@struts.apache.org>
> Sent: Sunday, April 03, 2005 4:25 PM
> Subject: Re: Form Submitted Twice
>
>
>
>>Martin,
>>
>>Thanks very much for the info.
>>
>>I've tried to follow this pattern, both in the servlet-mapping in the
>>web.xml:
>>
>>
>> <servlet-mapping>
>> <servlet-name>pets</servlet-name>
>> <url-pattern>/action/*</url-pattern>
>> </servlet-mapping>
>>
>>and in the action element in the struts-config:
>>
>> <action
>> path="/petDetail"
>> type="com.dom.struts.pets.action.PetDetailAction"
>> scope="request"
>> name="petDetailForm"
>> validate="true"
>> input="/petDetail.jsp">
>> <forward name="OwnerList" path="/action/getOwnerList"/>
>> <forward name="OwnerDetail" path="/action/ownerDetail"/>
>> <forward name="PetList" path="/action/getPetList"/>
>> <forward name="Success" path="/petDetail.jsp"/>
>> <forward name="Failure" path="/petDetail.jsp"/>
>> <forward name="Logoff" path="/action/logout"/>
>> </action>
>>
>>Evidently, something is not set up correctly, but it's not obvious to me
>>where the problem lies. I'm trying to step thru debug (using Eclipse
>>with Tomcat) to see if I can figure out what struts is having a problem
>>with.
>>
>>Thanks.
>>
>>Dom
>>
>>
>>Martin Gainty wrote:
>>
>>>Dom
>>>Apparently the action tag was not setup properly to ensure validation
>
> before
>
>>>posting to RequestProcessor
>>>To quote James Goodwill and Rick Hightower
>>>For the purposes of simplicity, our sample legacy Web resource will be a
>>>servlet. Essentially, you want the servlet's doGet method to be called
>
> only
>
>>>if the ActionForm validates
>>>e.g.
>>> <servlet-mapping>
>>> <servlet-name>legacy</servlet-name>
>>> <url-pattern>/legacy/roar</url-pattern>
>>> </servlet-mapping>
>>>
>>>Thus, posts to /legacy/roar would cause this servlet's doPost method to
>
> be
>
>>>called. Now, to map this servlet as an action that acts as a form
>
> handler,
>
>>>you need to do this:
>>>
>>> <action
>>> path="/legacy"
>>> forward="/legacy/roar"
>>> input="/form/userForm.jsp"
>>> name="userForm"
>>> parameter="/legacy/roar"
>>> validate="true"
>>> scope="request"
>>> />
>>>thus
>>>validate attribute is set to true in the action mapping for this
>
> servlet, so
>
>>>the execute method of the ForwardAction is called ONLY if the ActionForm
>>>(UserForm) validates (returns no ActionError objects).
>>>
>>>Makes sense?
>>>Martin-
>>>
>>>----- Original Message -----
>>>From: "Dom Incollingo" <Do...@austin.rr.com>
>>>To: "Struts User" <us...@struts.apache.org>
>>>Sent: Saturday, April 02, 2005 6:34 PM
>>>Subject: Form Submitted Twice
>>>
>>>
>>>
>>>
>>>>Hello,
>>>>
>>>>I'm using Struts 1.2.4 (along with the validator framework), and I've
>>>>noticed that for my forms that do a Post, the action class is executed
>>>>twice. I put log statements in my Action class, in the validator
>>>>classes, in the Struts ActionServlet, and in the JSP to try to figure
>>>>out what is happening. The sequence of events is as follows:
>>>>
>>>>- User presses Update button on a JSP
>>>>- doPost method invoked (ActionServlet)
>>>>- Struts validation methods invoked
>>>>- execute method (Action class) entered
>>>>- execute method (Action class) returns forward action of Success
>>>>- processing returns to the same JSP
>>
>>>.........................................................................
>>>
>>>>- doGet method invoked (ActionServlet)
>>>>- Struts validation methods invoked
>>>>- execute method (Action class) entered
>>>>- processing returns to the same JSP
>>>>- web page is displayed on browser
>>>>
>>>>Everything prior to the doGet looks normal. I can't understand why the
>>>>JSP submits a Get request when it should display. The method specified
>>>>in the JSP's form (there is only one form in the JSP) is a Post, not a
>>>>Get. The JSP does not contain any form submission via JavaScript.
>>>>
>>>>I also notice that if I change the method in the JSP's form from Post to
>>>>Get, this problem goes away: the form is submitted only once!
>>>>
>>>>In a related problem, I have a JSP that does have a form with a method
>>>>of Get, but the user never clicks on a button to submit the form.
>>>>Instead, the user clicks on a link with a value like:
>>>>
>>>
>>>
> http://localhost:8080/pets/action/petDetail?userAction=Display&type=Pet&id=2
>
>>>
>>>> I expect processing to go to the Action class associated with
>>>>'petDetail'. Processing does go there, but first a 'doGet' is processed
>>>>in the ActionServlet, even though a form was not submitted.
>>>>
>>>>Has anyone seen these problems or know what is happening here? Thanks
>>>>very much for your assistance.
>>>>
>>>>Dom
>>>>
>>>>---------------------------------------------------------------------
>>>>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>>For additional commands, e-mail: user-help@struts.apache.org
>>>>
>>>>
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>For additional commands, e-mail: user-help@struts.apache.org
>>>
>>
>>--
>>Linux is like a teepee: no Windows, no Gates, Apache inside.
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
--
Linux is like a teepee: no Windows, no Gates, Apache inside.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Form Submitted Twice
Posted by Martin Gainty <mg...@hotmail.com>.
Dom-
This depends on the return of your ActionForm validate method
If you can show us the code and I'll take a look at it tonite
Thanks,
Martin-
----- Original Message -----
From: "Dom Incollingo" <Do...@austin.rr.com>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Sunday, April 03, 2005 4:25 PM
Subject: Re: Form Submitted Twice
> Martin,
>
> Thanks very much for the info.
>
> I've tried to follow this pattern, both in the servlet-mapping in the
> web.xml:
>
>
> <servlet-mapping>
> <servlet-name>pets</servlet-name>
> <url-pattern>/action/*</url-pattern>
> </servlet-mapping>
>
> and in the action element in the struts-config:
>
> <action
> path="/petDetail"
> type="com.dom.struts.pets.action.PetDetailAction"
> scope="request"
> name="petDetailForm"
> validate="true"
> input="/petDetail.jsp">
> <forward name="OwnerList" path="/action/getOwnerList"/>
> <forward name="OwnerDetail" path="/action/ownerDetail"/>
> <forward name="PetList" path="/action/getPetList"/>
> <forward name="Success" path="/petDetail.jsp"/>
> <forward name="Failure" path="/petDetail.jsp"/>
> <forward name="Logoff" path="/action/logout"/>
> </action>
>
> Evidently, something is not set up correctly, but it's not obvious to me
> where the problem lies. I'm trying to step thru debug (using Eclipse
> with Tomcat) to see if I can figure out what struts is having a problem
> with.
>
> Thanks.
>
> Dom
>
>
> Martin Gainty wrote:
> > Dom
> > Apparently the action tag was not setup properly to ensure validation
before
> > posting to RequestProcessor
> > To quote James Goodwill and Rick Hightower
> > For the purposes of simplicity, our sample legacy Web resource will be a
> > servlet. Essentially, you want the servlet's doGet method to be called
only
> > if the ActionForm validates
> > e.g.
> > <servlet-mapping>
> > <servlet-name>legacy</servlet-name>
> > <url-pattern>/legacy/roar</url-pattern>
> > </servlet-mapping>
> >
> > Thus, posts to /legacy/roar would cause this servlet's doPost method to
be
> > called. Now, to map this servlet as an action that acts as a form
handler,
> > you need to do this:
> >
> > <action
> > path="/legacy"
> > forward="/legacy/roar"
> > input="/form/userForm.jsp"
> > name="userForm"
> > parameter="/legacy/roar"
> > validate="true"
> > scope="request"
> > />
> > thus
> > validate attribute is set to true in the action mapping for this
servlet, so
> > the execute method of the ForwardAction is called ONLY if the ActionForm
> > (UserForm) validates (returns no ActionError objects).
> >
> > Makes sense?
> > Martin-
> >
> > ----- Original Message -----
> > From: "Dom Incollingo" <Do...@austin.rr.com>
> > To: "Struts User" <us...@struts.apache.org>
> > Sent: Saturday, April 02, 2005 6:34 PM
> > Subject: Form Submitted Twice
> >
> >
> >
> >>Hello,
> >>
> >>I'm using Struts 1.2.4 (along with the validator framework), and I've
> >>noticed that for my forms that do a Post, the action class is executed
> >>twice. I put log statements in my Action class, in the validator
> >>classes, in the Struts ActionServlet, and in the JSP to try to figure
> >>out what is happening. The sequence of events is as follows:
> >>
> >>- User presses Update button on a JSP
> >>- doPost method invoked (ActionServlet)
> >>- Struts validation methods invoked
> >>- execute method (Action class) entered
> >>- execute method (Action class) returns forward action of Success
> >>- processing returns to the same JSP
>
>>.........................................................................
> >>- doGet method invoked (ActionServlet)
> >>- Struts validation methods invoked
> >>- execute method (Action class) entered
> >>- processing returns to the same JSP
> >>- web page is displayed on browser
> >>
> >>Everything prior to the doGet looks normal. I can't understand why the
> >>JSP submits a Get request when it should display. The method specified
> >>in the JSP's form (there is only one form in the JSP) is a Post, not a
> >>Get. The JSP does not contain any form submission via JavaScript.
> >>
> >>I also notice that if I change the method in the JSP's form from Post to
> >>Get, this problem goes away: the form is submitted only once!
> >>
> >>In a related problem, I have a JSP that does have a form with a method
> >>of Get, but the user never clicks on a button to submit the form.
> >>Instead, the user clicks on a link with a value like:
> >>
> >
> >
http://localhost:8080/pets/action/petDetail?userAction=Display&type=Pet&id=2
> >
> >
> >> I expect processing to go to the Action class associated with
> >>'petDetail'. Processing does go there, but first a 'doGet' is processed
> >>in the ActionServlet, even though a form was not submitted.
> >>
> >>Has anyone seen these problems or know what is happening here? Thanks
> >>very much for your assistance.
> >>
> >>Dom
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >>For additional commands, e-mail: user-help@struts.apache.org
> >>
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
>
> --
> Linux is like a teepee: no Windows, no Gates, Apache inside.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Form Submitted Twice
Posted by Dom Incollingo <Do...@austin.rr.com>.
Martin,
Thanks very much for the info.
I've tried to follow this pattern, both in the servlet-mapping in the
web.xml:
<servlet-mapping>
<servlet-name>pets</servlet-name>
<url-pattern>/action/*</url-pattern>
</servlet-mapping>
and in the action element in the struts-config:
<action
path="/petDetail"
type="com.dom.struts.pets.action.PetDetailAction"
scope="request"
name="petDetailForm"
validate="true"
input="/petDetail.jsp">
<forward name="OwnerList" path="/action/getOwnerList"/>
<forward name="OwnerDetail" path="/action/ownerDetail"/>
<forward name="PetList" path="/action/getPetList"/>
<forward name="Success" path="/petDetail.jsp"/>
<forward name="Failure" path="/petDetail.jsp"/>
<forward name="Logoff" path="/action/logout"/>
</action>
Evidently, something is not set up correctly, but it's not obvious to me
where the problem lies. I'm trying to step thru debug (using Eclipse
with Tomcat) to see if I can figure out what struts is having a problem
with.
Thanks.
Dom
Martin Gainty wrote:
> Dom
> Apparently the action tag was not setup properly to ensure validation before
> posting to RequestProcessor
> To quote James Goodwill and Rick Hightower
> For the purposes of simplicity, our sample legacy Web resource will be a
> servlet. Essentially, you want the servlet's doGet method to be called only
> if the ActionForm validates
> e.g.
> <servlet-mapping>
> <servlet-name>legacy</servlet-name>
> <url-pattern>/legacy/roar</url-pattern>
> </servlet-mapping>
>
> Thus, posts to /legacy/roar would cause this servlet's doPost method to be
> called. Now, to map this servlet as an action that acts as a form handler,
> you need to do this:
>
> <action
> path="/legacy"
> forward="/legacy/roar"
> input="/form/userForm.jsp"
> name="userForm"
> parameter="/legacy/roar"
> validate="true"
> scope="request"
> />
> thus
> validate attribute is set to true in the action mapping for this servlet, so
> the execute method of the ForwardAction is called ONLY if the ActionForm
> (UserForm) validates (returns no ActionError objects).
>
> Makes sense?
> Martin-
>
> ----- Original Message -----
> From: "Dom Incollingo" <Do...@austin.rr.com>
> To: "Struts User" <us...@struts.apache.org>
> Sent: Saturday, April 02, 2005 6:34 PM
> Subject: Form Submitted Twice
>
>
>
>>Hello,
>>
>>I'm using Struts 1.2.4 (along with the validator framework), and I've
>>noticed that for my forms that do a Post, the action class is executed
>>twice. I put log statements in my Action class, in the validator
>>classes, in the Struts ActionServlet, and in the JSP to try to figure
>>out what is happening. The sequence of events is as follows:
>>
>>- User presses Update button on a JSP
>>- doPost method invoked (ActionServlet)
>>- Struts validation methods invoked
>>- execute method (Action class) entered
>>- execute method (Action class) returns forward action of Success
>>- processing returns to the same JSP
>>.........................................................................
>>- doGet method invoked (ActionServlet)
>>- Struts validation methods invoked
>>- execute method (Action class) entered
>>- processing returns to the same JSP
>>- web page is displayed on browser
>>
>>Everything prior to the doGet looks normal. I can't understand why the
>>JSP submits a Get request when it should display. The method specified
>>in the JSP's form (there is only one form in the JSP) is a Post, not a
>>Get. The JSP does not contain any form submission via JavaScript.
>>
>>I also notice that if I change the method in the JSP's form from Post to
>>Get, this problem goes away: the form is submitted only once!
>>
>>In a related problem, I have a JSP that does have a form with a method
>>of Get, but the user never clicks on a button to submit the form.
>>Instead, the user clicks on a link with a value like:
>>
>
> http://localhost:8080/pets/action/petDetail?userAction=Display&type=Pet&id=2
>
>
>> I expect processing to go to the Action class associated with
>>'petDetail'. Processing does go there, but first a 'doGet' is processed
>>in the ActionServlet, even though a form was not submitted.
>>
>>Has anyone seen these problems or know what is happening here? Thanks
>>very much for your assistance.
>>
>>Dom
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
--
Linux is like a teepee: no Windows, no Gates, Apache inside.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Form Submitted Twice
Posted by Martin Gainty <mg...@hotmail.com>.
Dom
Apparently the action tag was not setup properly to ensure validation before
posting to RequestProcessor
To quote James Goodwill and Rick Hightower
For the purposes of simplicity, our sample legacy Web resource will be a
servlet. Essentially, you want the servlet's doGet method to be called only
if the ActionForm validates
e.g.
<servlet-mapping>
<servlet-name>legacy</servlet-name>
<url-pattern>/legacy/roar</url-pattern>
</servlet-mapping>
Thus, posts to /legacy/roar would cause this servlet's doPost method to be
called. Now, to map this servlet as an action that acts as a form handler,
you need to do this:
<action
path="/legacy"
forward="/legacy/roar"
input="/form/userForm.jsp"
name="userForm"
parameter="/legacy/roar"
validate="true"
scope="request"
/>
thus
validate attribute is set to true in the action mapping for this servlet, so
the execute method of the ForwardAction is called ONLY if the ActionForm
(UserForm) validates (returns no ActionError objects).
Makes sense?
Martin-
----- Original Message -----
From: "Dom Incollingo" <Do...@austin.rr.com>
To: "Struts User" <us...@struts.apache.org>
Sent: Saturday, April 02, 2005 6:34 PM
Subject: Form Submitted Twice
> Hello,
>
> I'm using Struts 1.2.4 (along with the validator framework), and I've
> noticed that for my forms that do a Post, the action class is executed
> twice. I put log statements in my Action class, in the validator
> classes, in the Struts ActionServlet, and in the JSP to try to figure
> out what is happening. The sequence of events is as follows:
>
> - User presses Update button on a JSP
> - doPost method invoked (ActionServlet)
> - Struts validation methods invoked
> - execute method (Action class) entered
> - execute method (Action class) returns forward action of Success
> - processing returns to the same JSP
> .........................................................................
> - doGet method invoked (ActionServlet)
> - Struts validation methods invoked
> - execute method (Action class) entered
> - processing returns to the same JSP
> - web page is displayed on browser
>
> Everything prior to the doGet looks normal. I can't understand why the
> JSP submits a Get request when it should display. The method specified
> in the JSP's form (there is only one form in the JSP) is a Post, not a
> Get. The JSP does not contain any form submission via JavaScript.
>
> I also notice that if I change the method in the JSP's form from Post to
> Get, this problem goes away: the form is submitted only once!
>
> In a related problem, I have a JSP that does have a form with a method
> of Get, but the user never clicks on a button to submit the form.
> Instead, the user clicks on a link with a value like:
>
http://localhost:8080/pets/action/petDetail?userAction=Display&type=Pet&id=2
> I expect processing to go to the Action class associated with
> 'petDetail'. Processing does go there, but first a 'doGet' is processed
> in the ActionServlet, even though a form was not submitted.
>
> Has anyone seen these problems or know what is happening here? Thanks
> very much for your assistance.
>
> Dom
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org