Web tier: servlets, JSP, Web frameworks: Struts: Iterating over an Array but creating a list with 2 lines

  1. Hi all,

    I want to create a list with 2 lines like what follows:

    hemistich1 hemistich2
    hemistich3 hemistich4
    hemistich5 hemistich6
    ... ...

    There's an Array of Strings containing content of the list
    ["hemistich1", "hemistich2", .....]

    I can't make 2 new Arrays out of the first one.

    I want to implement what intended using <logic:iterate> over the Array, any idea to do so? (Array content will be made dynamically)

    Thanks any way
    Majid Makki
  2. Hi,

    you can define a counter and evaluate the counter - every two iterations you can then insert a <br>:

    <logic:iterate name="theArray" id="element" indexId="index">
       <bean:write name="element"/>
       int idx = index.intValue();
       // idx starts with 0:
       if (idx % 2 == 1)

    Hope that helps,

    René Zanner