You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by "bphillips@ku.edu" <bp...@ku.edu> on 2014/01/16 14:45:07 UTC

Possible Bug When Using default-action-ref?

I'm working on JIRA issue https://issues.apache.org/jira/browse/WW-4259.  A
user reported that the action attribute of the form tag rendered by the
s:from tag included a duplicate amp (e.g. <form id="testform"
name="testform"
action="/formtest/TestPage.action?field1=111&amp;amp;field2=222"
method="post">

At first I could not duplicate the problem the user reported.

Then the user provided a Maven example project and running that project I
could duplicate the problem.

But I was wondering why I could not duplicate the problem in my own example
project.

I finally figured out that the user's project included a default-action-ref
statement in his struts.xml when mine did not.  Adding a default-action-ref
to my example enabled me to duplicate the user's problem.

What is strange is if you leave out the default-action-ref statement in the
struts.xml the s:form tag is rendered as <form id="testform" name="testform"
action="TestPage.action" method="post">

but with the default-action-ref statement in struts.xml the s:form tag is
rendered as <form id="testform" name="testform"
action="/formtest/TestPage.action?field1=111&amp;amp;field2=222"
method="post">

Anyone have some ideas of why the default-action-ref statement would cause
such as difference and if it should cause such a difference?

The example project submitted by the user is attached to the JIRA ticket. 
It may be helpful to read the comments int he JIRA ticket.

Thanks for the help.  I'm still new to the Struts 2 source code so if you
could point me in the right direction that would be great.

Bruce






--
View this message in context: http://struts.1045723.n5.nabble.com/Possible-Bug-When-Using-default-action-ref-tp5715093.html
Sent from the Struts - Dev mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Possible Bug When Using default-action-ref?

Posted by Lukasz Lenart <lu...@apache.org>.
Great! Very nice observation and corner case :-)


Kind regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

2014/1/19 bphillips@ku.edu <bp...@ku.edu>:
> I think I figured it out.
>
> In the testpage.jsp of his example he has this s:form tag:
>
> {code:XML}
> <s:form id="testform"
> action="TestPage.action?field1=%{field1}&field2=%{field2}">
>
> {code}
>
> Note the action="TestPage.action..."
>
> If you then do not have default-action-ref in struts.xml you will get the
> form tag rendered as
>
>   form id="testform" name="testform" action="TestPage.action" method="post"
>
> But if you remove the .action part (e.g. action="TestPage?field1..."  then
> it does not matter if you have the default-action-ref in struts.xml.  You
> get the correct form output of:
>
>
> action="/formtest-0.0.1-SNAPSHOT/TestPage.action?field1=111&amp;amp;field2=222
>
> (which includes the double amp which I know how to fix by a change in
> ServletUrlRenderer)
>
>
> My guess is that since TestPage.action does not match a  configured action
> Struts is treating that as a URI path and not an action.  Struts is ignoring
> the query string parameters if no default-action-ref is included.  If a
> default-action-ref is included in struts.xml then the query string
> parameters are included.
>
> Try some testing with action="TestPage.action..." in the s:form tag and with
> default-action-ref included and not included in struts.xml
>
> Bruce
>
>
>
>
> --
> View this message in context: http://struts.1045723.n5.nabble.com/Possible-Bug-When-Using-default-action-ref-tp5715093p5715107.html
> Sent from the Struts - Dev mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Possible Bug When Using default-action-ref?

Posted by "bphillips@ku.edu" <bp...@ku.edu>.
I think I figured it out.

In the testpage.jsp of his example he has this s:form tag:

{code:XML}
<s:form id="testform"
action="TestPage.action?field1=%{field1}&field2=%{field2}">

{code}

Note the action="TestPage.action..."  

If you then do not have default-action-ref in struts.xml you will get the
form tag rendered as 

  form id="testform" name="testform" action="TestPage.action" method="post" 

But if you remove the .action part (e.g. action="TestPage?field1..."  then
it does not matter if you have the default-action-ref in struts.xml.  You
get the correct form output of:

 
action="/formtest-0.0.1-SNAPSHOT/TestPage.action?field1=111&amp;amp;field2=222 

(which includes the double amp which I know how to fix by a change in
ServletUrlRenderer)


My guess is that since TestPage.action does not match a  configured action
Struts is treating that as a URI path and not an action.  Struts is ignoring
the query string parameters if no default-action-ref is included.  If a
default-action-ref is included in struts.xml then the query string
parameters are included.

Try some testing with action="TestPage.action..." in the s:form tag and with
default-action-ref included and not included in struts.xml

Bruce




--
View this message in context: http://struts.1045723.n5.nabble.com/Possible-Bug-When-Using-default-action-ref-tp5715093p5715107.html
Sent from the Struts - Dev mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Possible Bug When Using default-action-ref?

Posted by Lukasz Lenart <lu...@apache.org>.
Ok, let me test on Tomcat - I have just checked on Jetty. What url are
you using to test?


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

2014/1/19 bphillips@ku.edu <bp...@ku.edu>:
> Quite the mystery.
>
> I've run the example application on both GlassFish and Tomcat 7 using
> FireFox
>
> Without the default-action-ref in the struts.xml I see this when I view page
> source:
>
> {code:XML}
> <form id="testform" name="testform" action="TestPage.action" method="post">
>
>
>   field1 = 111</br/>
>   field2 = 222
>
> </form>
> {code}
>
> With the default-action-ref in the struts.xml I see this when I view page
> source:
>
> form id="testform" name="testform"
> action="/formtest-0.0.1-SNAPSHOT/TestPage.action?field1=111&amp;amp;field2=222"
> method="post">
>
>
>   field1 = 111</br/>
>   field2 = 222
>
> </form>
>
>
>
>
> --
> View this message in context: http://struts.1045723.n5.nabble.com/Possible-Bug-When-Using-default-action-ref-tp5715093p5715105.html
> Sent from the Struts - Dev mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Possible Bug When Using default-action-ref?

Posted by "bphillips@ku.edu" <bp...@ku.edu>.
Quite the mystery.

I've run the example application on both GlassFish and Tomcat 7 using
FireFox

Without the default-action-ref in the struts.xml I see this when I view page
source:

{code:XML}
<form id="testform" name="testform" action="TestPage.action" method="post">


  field1 = 111</br/>
  field2 = 222

</form>
{code}

With the default-action-ref in the struts.xml I see this when I view page
source:

form id="testform" name="testform"
action="/formtest-0.0.1-SNAPSHOT/TestPage.action?field1=111&amp;amp;field2=222"
method="post">


  field1 = 111</br/>
  field2 = 222

</form>




--
View this message in context: http://struts.1045723.n5.nabble.com/Possible-Bug-When-Using-default-action-ref-tp5715093p5715105.html
Sent from the Struts - Dev mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Possible Bug When Using default-action-ref?

Posted by Lukasz Lenart <lu...@apache.org>.
I have just tested this and don't see the difference with/without
<default-action-ref/> - maybe a browser is cheating you?

on FF and Ch is the same

<form id="testform" name="testform"
action="/formtest/TestPage.action?field1=111&amp;amp;field2=222"
method="post">


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

2014/1/19 bphillips@ku.edu <bp...@ku.edu>:
> Appreciate the responses but perhaps I wasn't clear.
>
> What I'm trying to research is why if using a default-action-ref statement
> in struts.xml the query string parameters and values are included in the
> form action attribute (although with an incorrectly encoded &) but if no
> default-action-ref statement is in struts.xml then no query string
> parameters and values are included (e.g. action="TestPage.action").
>
> I've studied ServletUrlRenderer and DefaultUrlHelper but cannot figure it
> out.
>
> Bruce
>
>
>
> --
> View this message in context: http://struts.1045723.n5.nabble.com/Possible-Bug-When-Using-default-action-ref-tp5715093p5715103.html
> Sent from the Struts - Dev mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Possible Bug When Using default-action-ref?

Posted by "bphillips@ku.edu" <bp...@ku.edu>.
Appreciate the responses but perhaps I wasn't clear.

What I'm trying to research is why if using a default-action-ref statement
in struts.xml the query string parameters and values are included in the
form action attribute (although with an incorrectly encoded &) but if no
default-action-ref statement is in struts.xml then no query string
parameters and values are included (e.g. action="TestPage.action").

I've studied ServletUrlRenderer and DefaultUrlHelper but cannot figure it
out.  

Bruce



--
View this message in context: http://struts.1045723.n5.nabble.com/Possible-Bug-When-Using-default-action-ref-tp5715093p5715103.html
Sent from the Struts - Dev mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Possible Bug When Using default-action-ref?

Posted by Paul Benedict <pb...@apache.org>.
The string being shown in the email is: &amp;amp;

So that means the output should be a literal "&amp;" but why? Why would you
want to output that? I think the error is the extra "amp;"


On Thu, Jan 16, 2014 at 12:39 PM, Chris Pratt <th...@gmail.com>wrote:

> It's apparently being double-XML-encoded.  The first time changes & to
> &amp;, the second time changes &amp; to &amp;amp;.  I'd look at the code
> where default-action-ref is used, it must be XML-encoding the URL that was
> formerly XML-encoded.  Just my 2 cents.
>   (*Chris*)
>
>
> On Thu, Jan 16, 2014 at 5:45 AM, bphillips@ku.edu <bp...@ku.edu>
> wrote:
>
> > I'm working on JIRA issue https://issues.apache.org/jira/browse/WW-4259.
> >  A
> > user reported that the action attribute of the form tag rendered by the
> > s:from tag included a duplicate amp (e.g. <form id="testform"
> > name="testform"
> > action="/formtest/TestPage.action?field1=111&amp;amp;field2=222"
> > method="post">
> >
> > At first I could not duplicate the problem the user reported.
> >
> > Then the user provided a Maven example project and running that project I
> > could duplicate the problem.
> >
> > But I was wondering why I could not duplicate the problem in my own
> example
> > project.
> >
> > I finally figured out that the user's project included a
> default-action-ref
> > statement in his struts.xml when mine did not.  Adding a
> default-action-ref
> > to my example enabled me to duplicate the user's problem.
> >
> > What is strange is if you leave out the default-action-ref statement in
> the
> > struts.xml the s:form tag is rendered as <form id="testform"
> > name="testform"
> > action="TestPage.action" method="post">
> >
> > but with the default-action-ref statement in struts.xml the s:form tag is
> > rendered as <form id="testform" name="testform"
> > action="/formtest/TestPage.action?field1=111&amp;amp;field2=222"
> > method="post">
> >
> > Anyone have some ideas of why the default-action-ref statement would
> cause
> > such as difference and if it should cause such a difference?
> >
> > The example project submitted by the user is attached to the JIRA ticket.
> > It may be helpful to read the comments int he JIRA ticket.
> >
> > Thanks for the help.  I'm still new to the Struts 2 source code so if you
> > could point me in the right direction that would be great.
> >
> > Bruce
> >
> >
> >
> >
> >
> >
> > --
> > View this message in context:
> >
> http://struts.1045723.n5.nabble.com/Possible-Bug-When-Using-default-action-ref-tp5715093.html
> > Sent from the Struts - Dev mailing list archive at Nabble.com.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> > For additional commands, e-mail: dev-help@struts.apache.org
> >
> >
>



-- 
Cheers,
Paul

Re: Possible Bug When Using default-action-ref?

Posted by Chris Pratt <th...@gmail.com>.
It's apparently being double-XML-encoded.  The first time changes & to
&amp;, the second time changes &amp; to &amp;amp;.  I'd look at the code
where default-action-ref is used, it must be XML-encoding the URL that was
formerly XML-encoded.  Just my 2 cents.
  (*Chris*)


On Thu, Jan 16, 2014 at 5:45 AM, bphillips@ku.edu <bp...@ku.edu> wrote:

> I'm working on JIRA issue https://issues.apache.org/jira/browse/WW-4259.
>  A
> user reported that the action attribute of the form tag rendered by the
> s:from tag included a duplicate amp (e.g. <form id="testform"
> name="testform"
> action="/formtest/TestPage.action?field1=111&amp;amp;field2=222"
> method="post">
>
> At first I could not duplicate the problem the user reported.
>
> Then the user provided a Maven example project and running that project I
> could duplicate the problem.
>
> But I was wondering why I could not duplicate the problem in my own example
> project.
>
> I finally figured out that the user's project included a default-action-ref
> statement in his struts.xml when mine did not.  Adding a default-action-ref
> to my example enabled me to duplicate the user's problem.
>
> What is strange is if you leave out the default-action-ref statement in the
> struts.xml the s:form tag is rendered as <form id="testform"
> name="testform"
> action="TestPage.action" method="post">
>
> but with the default-action-ref statement in struts.xml the s:form tag is
> rendered as <form id="testform" name="testform"
> action="/formtest/TestPage.action?field1=111&amp;amp;field2=222"
> method="post">
>
> Anyone have some ideas of why the default-action-ref statement would cause
> such as difference and if it should cause such a difference?
>
> The example project submitted by the user is attached to the JIRA ticket.
> It may be helpful to read the comments int he JIRA ticket.
>
> Thanks for the help.  I'm still new to the Struts 2 source code so if you
> could point me in the right direction that would be great.
>
> Bruce
>
>
>
>
>
>
> --
> View this message in context:
> http://struts.1045723.n5.nabble.com/Possible-Bug-When-Using-default-action-ref-tp5715093.html
> Sent from the Struts - Dev mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>