I am dealing with a legacy system that has track of all past exams and the topics that has been covered in each.
For example:
Exam1 1/1/1980
topicID topicName topicRFCode Description
1 AAA 1 fdfdfgfdgdf
1 AAA 2 cvcvcvcvcv
20 XXX 1 asasasasas
12 MMM 3 klklklkl
12 MMM 1 erererer
12 MMM 2 jkjkjkjkjkjk
As you can see, three different topics were covered in 1/1/1980 exam. Two questions were related to topic AAA One question was related to topic XXX and three questions were related to topic MMM.
Java passes a list of topics that are related to the selected exam to JSP then I try to show descriptions of each topic separately, I have following
<c:forEach var="topic" items="${topics}" >
<c:if test="${topic.topicId == '1'}">
<c:forEach var="aaa" items="${topics}">
<c:if test="${aaa.topicId == '1'}">
<p>${aaa.description}</p>
</c:if>
</c:forEach>
</c:if>
</c:forEach>
The problems are:
- Current code has two for loops so for each topic I should have a separate pair of codes as I want to show all descriptions for each topic one after another.
- Because of multiple for loops it is quite slow.
- Not sure if this is the best approach to the issue.