2

In my jsp:

<jsp:useBean id = "b" class = "pack1.userBean" scope="application" />
            <tr>
                    <td> <c:out value ="firstName"/> </td>
                    <td> <c:out value ="${b.firstName}"/> </td>
            </tr>  

            <tr>
                    <td> <c:out value ="lastName"/> </td>
                    <td> <c:out value ="${b.lastName}"/> </td>
            </tr> 

This is working fine, but how can i iterate each value from userBean in a loop instead of typing each value over and over ?

Look like: (doesn't work)

         <c:forEach var="p" items="${b}">
            <tr>
                <td> <c:out value ="${p.key}"/> </td>
                <td> <c:out value ="${p.value}"/> </td>
            </tr>
        </c:forEach>

header: (working fine)

    <c:forEach var="h" items="${header}">
        <tr>
            <td> <c:out value ="${h.key}"/> </td>
            <td> <c:out value ="${h.value}"/> </td>
        </tr>
    </c:forEach>

Can anyone help? Thanks.

Jam
  • 113
  • 2
  • 7
  • 1
    If you want to iterate through all attributes defined in the bean, I think this will help http://stackoverflow.com/questions/16302554/view-all-attributes-of-java-object-in-jsp-jstl – RubioRic Apr 10 '16 at 05:47

0 Answers0