views:

95

answers:

1

I am trying to get an html page like http://jsbin.com/awoco

This is a JSP page so it will include scriptlet. Final html will be kind of like this (i left tags unclosed to save space):

<%
Iterator it = MyList.iterator()
      While (it.hasNext())
      SomeClass all = it.next();
      SomeClass a = it.next();
      SomeClass b = it.next();
%>
      <tr> 
        <td rowspan=3 valign=top>Red<td><%=all.Name()%><td><%=all.price()%><td><%=all.originalPrice()%> 
      </tr> 
      <tr> 
        <td><%=a.Name()%><td><%=a.price()%><td><%=a.originalPrice()%> 
      </tr>  
      <tr >
        <td><%=b.Name()%><td><%=b.price()%><td><%=b.originalPrice()%>
      </tr>

As you can see, I have to call next 3 times inside the while loop because the List that I getting with the data is populated that way and I have to show the data in exact same way as the link provided above.

Is there a way to change the html somehow so that I dont have to call next more than once but still get the same table structure.

...If you want to know why I dont want to call next more than once then please see the edit :)

A: 

Change your data structures. MyList should be list of (something like) AgregateClass which will contain 3 members of type SomeClass (all,a,b) and then simply iterate through MyList.

Just few tips: If you are using Struts2 you can use <s:iterator> tag to iterate through collections. documentation

Since JSP 2.0 or so you can write ${b.price} instead of <%=b.price()%>

You should change tags you added to your question as it has nothing to do with html or css.

rdk