You have the sense and structure of the loops correct; I believe that
you're just referring to properties with the wrong names. Without a
BeanInfo class, the method "getMy_StringA()" turns into the property
"my_StringA", not "My_StringA". (Note the initial lowercase character.)
It's more typical in Java not to include the "_", but this doesn't change
the way that JavaBean accessors are interpreted by the Introspector.
Thus, if you try the following instead, it should work:
<table>
<c:forEach var="test1" items="${X}">
<tr>
<td><c:out value="${test1.my_StringA}"/></td>
</tr>
<c:forEach var="test2" items="${test1[my_List]}">
<tr>
<td><c:out value="${test2.my_StringB}"/></td>
</tr>
</c:forEach>
</c:forEach>
</table>
--
Shawn Bayern
"JSTL in Action" http://www.jstlbook.com
(coming in July 2002 from Manning Publications)
On Thu, 18 Jul 2002, Marino Tudor wrote:
> I have class A and class B where
> class A hold a Collection of calss B in "My_List".
> ******************************************
> public class A {
> private String My_StringA;
> private java.util.List My_List;
>
> public void setMy_StringA(String param){
> this.My_StringA = param;
> }
> public String getMy_StringA(){
> return this.My_StringA;
> }
>
> public void setMy_List(java.util.List param){
> this.My_List = param;
> }
> public List getMy_List(){
> return this.My_List;
> }
> }
> ***************************
> public class B {
> private String My_StringB;
> public void setMy_StringB(String param){
> this.My_StringB = param;
> }
> public String getMy_StringB(){
> return this.My_StringB;
> }
> }
> ***********************************
>
> Let's say that I have a Collection of class A saved
> in request attribute called "X".
> (request.setAttribute("X", ... collection of classes A);
>
> How can I print out all My_StrigsB for every calss of A using JSTL forEach ?
>
> I tried something like this, but it didn't work:
>
> <table>
> <c:forEach var="test1" items="${X}">
> <tr>
> <td><c:out value="${test1.My_StringA}"/></td>
> </tr>
> <c:forEach var="test2" items="${test1[My_List]}">
> <tr>
> <td><c:out value="${test2.My_StringB}"/></td>
> </tr>
> </c:forEach>
> </c:forEach>
> </table>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>