Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Comparing two lists in JSTL  RSS feed

 
chandra ganesh
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello every one i am having two lists in my jsp which are coming from controller class
animals ={ant,deer,lion,tiger}
carnivores={lion,tiger}

now i have to compare both the lists using jstl and print animals which are herbivores and which are carnivores
<c:forEach items="${animals}" var="module">
<c:forEach items="${carnivores}" var="fmodule">
<c:choose>
<c:when test="${fmodule eq module}">
${module} <br>
</c:when>
<c:otherwise>
${module}
</c:otherwise>
</c:choose>
</c:forEach>
</c:forEach>
what i did is the above one i am getting carnivores but all animals are repeating for each loop so can any one suggest me a solution for this
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66144
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why isn't this being done in the controller? The JSP is not the place for computations.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!