0

I Have a special occasion to iterate an hashSet object . I've passed an attribute on a .jsp page this attribute has a parameter which is type of Hash set and I knew I can iterate it with foreach but the problem is that I can't print the right value under the right associated header in a table format .
Imagine I have this jsp page :

<html>
    <head>
    </head>
    <body>
        <div class="container">
            <table class="table table-hover">
                <thead>
                <tr>
                    <th>A</th>
                    <th>B</th>
                    <th>C</th>
                    <th>D</th>
                </tr>
                </thead>
                <tbody>
                <c:forEach var="vacation" items="${vacationList}">
                    <tr>
                        <td><c:out value="${vacation.vacationId}"/></td>
                        <td><c:out value="${vacation.startDate}"/></td>
                        <c:forEach var="vacationCategory" items="${vacationList.categoryElements}">
                             <td><c:out value="${vacationCategory.name}"/></td>
                        </c:forEach>    
                    </tr>
                </c:forEach>
                </tbody>
            </table>
        </div>
      </body>
      </html>

in this example vacationId will print under A column and startDate will print under B column and there are 2 parameters in the categoryElements so that I used foreach to print each of them separately under C and D columns . and it will print them separately but the Main problem is that :
fro example with first request it will print table's data like this
A(12) B(2020) C(ww) D(qq)
and when ever I refresh the page or send another request (ww) and (qq) will change their position, it will be like this :
A(12) B(2020) C(qq) D(ww)
I think there should be something that link a <td> tag to proper <th> . something like id

I totally get crazy with this problem please give me some solution.

leylihz
  • 15
  • 5

0 Answers0