1

I have this code to send two Lists for iterating

 request.setAttribute("PopulateAgentList", agentList);
 request.setAttribute("PopulateAgentContactList",agentContactList);

I can iterate through only one List usijng this code.

<c:forEach var="PopulateAgentList" items="${requestScope['PopulateAgentList']}">
        <tr>
            <td><c:out value="${PopulateAgentList.name}"/></td>
            <td><c:out value="${PopulateAgentList.country}"/></td>
            <td>Edinburgh</td>
            <td>61</td>
        </tr>
        </c:forEach>

Can I iterate through the both "PopulateAgentContactList" and "PopulateAgentList".

1
  • 2
    That simply shows a design problem. Instead of having two parallel lists, you should have a single one , where each object inside the list would contain an agent and a contact. Commented Feb 12, 2015 at 12:58

1 Answer 1

3

Yes, this answer here explains a way to do this

In your situation, you would do something like this:

<c:forEach var="PopulateAgentList" items="${people.firstnames}" varStatus="status">
    <tr>
        <td><c:out value="${PopulateAgentList.name}"/></td>
        <td><c:out value="${PopulateAgentList.country}"/></td>
        <td><c:out value="${PopulateAgentContactList[status.index].whatever}"/></td>
    </tr>
</c:forEach>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.