Struts 1
  1. Struts 1
  2. STR-1301

<nested:iterate> loses index with jsp:include

    Details

    • Type: Bug Bug
    • Status: Reopened
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 1.1.0
    • Fix Version/s: Future
    • Component/s: Tag Libraries
    • Labels:
      None
    • Environment:
      Operating System: Windows XP
      Platform: PC

      Description

      POTENTIAL BUG:
      When using nested:interate and placing a jsp:include in the iteration, the
      included jsp cannot retrieve the proper nesting level. Thus any form related
      nested tags are possibly named with duplicate names. ie:

      <input hidden="name[0]" value="name1"/>
      <input hidden="name[0]" value="name2"/>

      COMMENT OF NOTE:
      It appears that tag does NOT lose the actual underlying beans,
      it just loses the proper naming of the index.

      SIMPLE EXAMPLE:

          • testNestedIterate.jsp =
            <nested:root name="narray">
            <nested:iterate property="names">
            BEFORE: <nested:writeNesting /><br />
            <jsp:include page="testNestedIterateInclude.jsp" />
            </nested:iterate>
            </nested:root>
          • testNestedIterateInclude.jsp =
            <nested:root>
            AFTER: <nested:writeNesting />
            Name in bytes: <nested:write property="bytes"/><p />
            </nested:root>

      I will attach the test class throwaway.test.Names
      in a subsequent comment to help document this problem better.
      I've tried to seriously test this before submitting this as
      bug so if any further information is needed please reach me
      at cbutler@mateso.com.

      1. ASF.LICENSE.NOT.GRANTED--Names.java
        0.3 kB
        Chris Butler
      2. ASF.LICENSE.NOT.GRANTED--testNestedIterate.jsp
        0.5 kB
        Chris Butler
      3. ASF.LICENSE.NOT.GRANTED--testNestedIterateInclude.jsp
        0.3 kB
        Chris Butler
      4. ASF.LICENSE.NOT.GRANTED--requestScope.jsp
        1 kB
        Chris Butler
      5. ASF.LICENSE.NOT.GRANTED--testNestedIterateInclude.jsp
        0.7 kB
        Chris Butler
      6. ASF.LICENSE.NOT.GRANTED--testNestedIterateInclude2.jsp
        0.1 kB
        Chris Butler
      7. ASF.LICENSE.NOT.GRANTED--StrutsBaseForm.java
        2 kB
        Christine
      8. ASF.LICENSE.NOT.GRANTED--StrutsInnerBean.java
        1 kB
        Christine
      9. ASF.LICENSE.NOT.GRANTED--testBase.jsp
        0.4 kB
        Christine
      10. ASF.LICENSE.NOT.GRANTED--testInnerOne.jsp
        0.8 kB
        Christine
      11. ASF.LICENSE.NOT.GRANTED--testInnerJunk.jsp
        0.2 kB
        Christine
      12. ASF.LICENSE.NOT.GRANTED--testInnerTwo.jsp
        0.3 kB
        Christine

        Issue Links

          Activity

          Hide
          Chris Butler added a comment -

          Created an attachment (id=5329)
          Names.java = Test object to store a simple array

          Show
          Chris Butler added a comment - Created an attachment (id=5329) Names.java = Test object to store a simple array
          Hide
          Chris Butler added a comment -

          Created an attachment (id=5330)
          testNestedIterate.jsp = top level test, w/simple jsp

          Show
          Chris Butler added a comment - Created an attachment (id=5330) testNestedIterate.jsp = top level test, w/simple jsp
          Hide
          Chris Butler added a comment -

          Created an attachment (id=5331)
          testNestedIterateInclude.jsp = jsp:include called by testNestedIterate

          Show
          Chris Butler added a comment - Created an attachment (id=5331) testNestedIterateInclude.jsp = jsp:include called by testNestedIterate
          Hide
          Chris Butler added a comment -

          Created an attachment (id=5332)
          requestScope.jsp = dumps the request scope in HTML table

          Show
          Chris Butler added a comment - Created an attachment (id=5332) requestScope.jsp = dumps the request scope in HTML table
          Hide
          Arron Bates added a comment -

          Need to have this bug confirmed against a nightly build to get the the latest
          nested tags. For just the tags, download...

          http://keyboardmonkey.com/downloads/km-nested-v2.03.jar

          Show
          Arron Bates added a comment - Need to have this bug confirmed against a nightly build to get the the latest nested tags. For just the tags, download... http://keyboardmonkey.com/downloads/km-nested-v2.03.jar
          Hide
          Chris Butler added a comment -

          Found that there are problems with nested tags when
          a 2nd jsp include is placed in the 1st jsp include,
          and the 2nd jsp include has a <nested:root> element... ie:

          top jsp:
          ...

          inner1.jsp:
          <nested:root>
          <nested:notEqual property="bytes" value="gunk1">
          <jsp:include page="inner2.jsp" />
          </nested:notEqual>

          <!-- THE REQUEST SCOPE VAR BECOMES "nestOne" here = bug -->
          <nested:notEqual property="bytes" value="gunk2">
          <jsp:include page="inner2.jsp" />
          </nested:notEqual>
          </nested:root>

          inner2.jsp
          <nested:root>
          <nested:write property="bytes" />
          </nested:root>

          Attached is two more examples jsp.
          Use testNestedIterate.jsp and Names.java from previous attachments.

          Show
          Chris Butler added a comment - Found that there are problems with nested tags when a 2nd jsp include is placed in the 1st jsp include, and the 2nd jsp include has a <nested:root> element... ie: top jsp: ... inner1.jsp: <nested:root> <nested:notEqual property="bytes" value="gunk1"> <jsp:include page="inner2.jsp" /> </nested:notEqual> <!-- THE REQUEST SCOPE VAR BECOMES "nestOne" here = bug --> <nested:notEqual property="bytes" value="gunk2"> <jsp:include page="inner2.jsp" /> </nested:notEqual> </nested:root> inner2.jsp <nested:root> <nested:write property="bytes" /> </nested:root> Attached is two more examples jsp. Use testNestedIterate.jsp and Names.java from previous attachments.
          Hide
          Chris Butler added a comment -

          Created an attachment (id=5347)
          testIterateInclude.jsp (new) - new version for testing 3 levels of include

          Show
          Chris Butler added a comment - Created an attachment (id=5347) testIterateInclude.jsp (new) - new version for testing 3 levels of include
          Hide
          Chris Butler added a comment -

          Created an attachment (id=5348)
          testNestedIterateInclude2.jsp - most inner jsp include (has nested:root)

          Show
          Chris Butler added a comment - Created an attachment (id=5348) testNestedIterateInclude2.jsp - most inner jsp include (has nested:root)
          Hide
          Ted Husted added a comment -

          I'm not sure that nested includes within nested tags is required behavior for
          the 1.1 release, so I'm marking it for the 1.2 family. The issue was originally
          posted against RC1.

          Show
          Ted Husted added a comment - I'm not sure that nested includes within nested tags is required behavior for the 1.1 release, so I'm marking it for the 1.2 family. The issue was originally posted against RC1.
          Hide
          Arron Bates added a comment -

          Includes were supported since March or something last year, and this appears to
          be a problem with the new tomcat which recent code targeted for 1.1 RC2 is
          trying to fix.

          As a result, moving it back to the 1.1 family.

          Show
          Arron Bates added a comment - Includes were supported since March or something last year, and this appears to be a problem with the new tomcat which recent code targeted for 1.1 RC2 is trying to fix. As a result, moving it back to the 1.1 family.
          Hide
          Arron Bates added a comment -

          Used the supplied tests and ran it against the latest nested taglib, and
          couldn't reproduce the error, even adding arbitrarily more complex
          nesting/inclusion scenarios.

          Thanks Chris for the supplied JSP's to test against.
          Pick up the new tags as linked or wait for the impending RC2 when it happens.

          If the problem does indeed persist, feel free to reopen the bug.

          For now, marking it as fixed by the last update of the nested tags.

          Show
          Arron Bates added a comment - Used the supplied tests and ran it against the latest nested taglib, and couldn't reproduce the error, even adding arbitrarily more complex nesting/inclusion scenarios. Thanks Chris for the supplied JSP's to test against. Pick up the new tags as linked or wait for the impending RC2 when it happens. If the problem does indeed persist, feel free to reopen the bug. For now, marking it as fixed by the last update of the nested tags.
          Hide
          Arron Bates added a comment -

          Tibor Varga found what we believe to be the real source of the problem. A bad
          reference to a nesting in NestedRootTag. Quite subtle, only happens on a second
          include to a page where a closing nested:root tag puts the wrong nesting context
          into the works.

          Thanks Tibor.

          Show
          Arron Bates added a comment - Tibor Varga found what we believe to be the real source of the problem. A bad reference to a nesting in NestedRootTag. Quite subtle, only happens on a second include to a page where a closing nested:root tag puts the wrong nesting context into the works. Thanks Tibor.
          Hide
          Christine added a comment -

          Re-opened the 17977 defect.

          DESCRIPTION OF POTENTIAL BUG:
          When using more than one jsp:include within a JSP and combined with the
          nested:root, the proper nesting level becomes incorrect or inaccessible. Any
          JSP which has more than one nested jsp:include will fail upon return from the
          inclusion at the next nested call to retrieve a property at the current nesting
          level. An interesting note: the following example works when using the Struts
          1.1 Beta 2 jar, but fails when using the RC2 jar.

          EXAMPLE:
          The following example code is attached to allow for recreation. This code was
          deployed and tested running on JBoss 3.2 with the distributed/included Tomcat
          version.

                        • StrutsBaseForm.java
                          public class StrutsBaseForm extends ActionForm
                          implements java.io.Serializable {
                          //--------------------
                          //- MEMBER VARIABLES -
                          //--------------------
                          public ArrayList listBeans = null;
                          public String junk = null;

          //----------------
          //- CONSTRUCTOR -
          //----------------
          public StrutsBaseForm()

          { // Pre-populate the objects with dummy information this.listBeans = new ArrayList(); this.listBeans.add(new StrutsInnerBean("One", "1")); this.listBeans.add(new StrutsInnerBean("Two", "2")); this.listBeans.add(new StrutsInnerBean("Three", "3")); this.listBeans.add(new StrutsInnerBean("Four", "4")); this.listBeans.add(new StrutsInnerBean("Five", "5")); this.junk = "1"; }

          .... accessor methods not listed
          } // End class StrutsBaseForm

                        • StrutsInnerBean.java
                          public class StrutsInnerBean implements java.io.Serializable {
                          //--------------------
                          //- MEMBER VARIABLES -
                          //--------------------
                          public String displayLabel = null;
                          public String displayValue = null;

          //----------------
          //- CONSTRUCTOR -
          //----------------
          public StrutsInnerBean(String displayLabel, String displayValue)

          { // Pre-populate the objects this.displayLabel = displayLabel; this.displayValue = displayValue; }

          .... accessor methods not listed
          } // End class StrutsInnerBean

                        • testBase.jsp
                          <%-- Uses defined form-bean referencing the StrutsBaseForm class --%>
                          <nested:form action="/testNested.do" >
                          <jsp:include page="testInnerOne.jsp" />
                          </nested:form>
                        • testInnerOne.jsp
                          <nested:root>
                          <nested:present property="listBeans">
                          <nested:iterate id="currentBean" property="listBeans">
                          <jsp:include page="testInnerTwo.jsp" />
                          </nested:iterate>
                          </nested:present>

          <%-- At this point, the JSP errors with an exception stating:
          JasperException: No bean found under attribute key --%>
          <nested:equal property="junk" value="1">
          <jsp:include page="testInnerJunk.jsp" />
          </nested:equal>
          </nested:root>

                        • testInnerTwo.jsp
                          <nested:root>
                          <nested:write property="displayLabel" />: 
                          <nested:text property="displayValue" size="30" />
                          </nested:root>
                        • testInnerJunk.jsp
                          <nested:root>
                          Inner junk value: <nested:write property="junk" />
                          </nested:root>

          Please feel free to contact me for information: ckudlac@hotmail.com.

          Show
          Christine added a comment - Re-opened the 17977 defect. DESCRIPTION OF POTENTIAL BUG: When using more than one jsp:include within a JSP and combined with the nested:root, the proper nesting level becomes incorrect or inaccessible. Any JSP which has more than one nested jsp:include will fail upon return from the inclusion at the next nested call to retrieve a property at the current nesting level. An interesting note: the following example works when using the Struts 1.1 Beta 2 jar, but fails when using the RC2 jar. EXAMPLE: The following example code is attached to allow for recreation. This code was deployed and tested running on JBoss 3.2 with the distributed/included Tomcat version. StrutsBaseForm.java public class StrutsBaseForm extends ActionForm implements java.io.Serializable { //-------------------- //- MEMBER VARIABLES - //-------------------- public ArrayList listBeans = null; public String junk = null; //---------------- //- CONSTRUCTOR - //---------------- public StrutsBaseForm() { // Pre-populate the objects with dummy information this.listBeans = new ArrayList(); this.listBeans.add(new StrutsInnerBean("One", "1")); this.listBeans.add(new StrutsInnerBean("Two", "2")); this.listBeans.add(new StrutsInnerBean("Three", "3")); this.listBeans.add(new StrutsInnerBean("Four", "4")); this.listBeans.add(new StrutsInnerBean("Five", "5")); this.junk = "1"; } .... accessor methods not listed } // End class StrutsBaseForm StrutsInnerBean.java public class StrutsInnerBean implements java.io.Serializable { //-------------------- //- MEMBER VARIABLES - //-------------------- public String displayLabel = null; public String displayValue = null; //---------------- //- CONSTRUCTOR - //---------------- public StrutsInnerBean(String displayLabel, String displayValue) { // Pre-populate the objects this.displayLabel = displayLabel; this.displayValue = displayValue; } .... accessor methods not listed } // End class StrutsInnerBean testBase.jsp <%-- Uses defined form-bean referencing the StrutsBaseForm class --%> <nested:form action="/testNested.do" > <jsp:include page="testInnerOne.jsp" /> </nested:form> testInnerOne.jsp <nested:root> <nested:present property="listBeans"> <nested:iterate id="currentBean" property="listBeans"> <jsp:include page="testInnerTwo.jsp" /> </nested:iterate> </nested:present> <%-- At this point, the JSP errors with an exception stating: JasperException: No bean found under attribute key --%> <nested:equal property="junk" value="1"> <jsp:include page="testInnerJunk.jsp" /> </nested:equal> </nested:root> testInnerTwo.jsp <nested:root> <nested:write property="displayLabel" />:  <nested:text property="displayValue" size="30" /> </nested:root> testInnerJunk.jsp <nested:root> Inner junk value: <nested:write property="junk" /> </nested:root> Please feel free to contact me for information: ckudlac@hotmail.com.
          Hide
          Christine added a comment -

          Created an attachment (id=9412)
          Form bean for test

          Show
          Christine added a comment - Created an attachment (id=9412) Form bean for test
          Hide
          Christine added a comment -

          Created an attachment (id=9413)
          StrutsInnerBean.java = Inner bean object for testing with strutsBase.jsp

          Show
          Christine added a comment - Created an attachment (id=9413) StrutsInnerBean.java = Inner bean object for testing with strutsBase.jsp
          Hide
          Christine added a comment -

          Created an attachment (id=9414)
          testBase.jsp - JSP used to define for strutsForm for testing

          Show
          Christine added a comment - Created an attachment (id=9414) testBase.jsp - JSP used to define for strutsForm for testing
          Hide
          Christine added a comment -

          Created an attachment (id=9415)
          testInnerOne.jsp - JSP used with testBasejsp

          Show
          Christine added a comment - Created an attachment (id=9415) testInnerOne.jsp - JSP used with testBasejsp
          Hide
          Christine added a comment -

          Created an attachment (id=9416)
          testInnerJunk.jsp - JSP used with testBasejsp

          Show
          Christine added a comment - Created an attachment (id=9416) testInnerJunk.jsp - JSP used with testBasejsp
          Hide
          Christine added a comment -

          Created an attachment (id=9417)
          testInnerTwo.jsp - JSP used with testBase.jsp

          Show
          Christine added a comment - Created an attachment (id=9417) testInnerTwo.jsp - JSP used with testBase.jsp
          Hide
          Christine added a comment -

          Added the version number.

          Show
          Christine added a comment - Added the version number.
          Hide
          Ted Husted added a comment -

          Marking "LATER" pending a course of action.

          Show
          Ted Husted added a comment - Marking "LATER" pending a course of action.
          Hide
          Ted Husted added a comment -

          Marking "LATER" pending course of action.

          Show
          Ted Husted added a comment - Marking "LATER" pending course of action.
          Hide
          David Graham added a comment -

          Reopening to mark as LATER.

          Show
          David Graham added a comment - Reopening to mark as LATER.

            People

            • Assignee:
              Unassigned
              Reporter:
              Chris Butler
            • Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:

                Development