Advertisement

07.05.2008 at 08:46PM PDT, ID: 23541247
[x]
Attachment Details

How do I test an attribute inside a c:forEach element?

Asked by josecuadra in Java Server Pages (JSP), Java Servlets, Java Standard Tag Library (JSTL) & Server Tags

Tags: Java

Hello,

My situation is as follows. I am using the core JSTL, specifically the c:forEach instruction. Due to some logic I've developed, this forEach could receive two different Lists (passed by the request object), but one of them is null. I need to test which one of the Lists comes with stuff. For simplicity, let's assume both lists have the same elements so the main issue won't be the forEach's body.  

The code I tried to develop was similar to the one I'm attaching, but it won't seem to work.

Any help on this issue is appreciated.

Start Free Trial
1:
<c:forEach items="<c:choose><c:when test='${list1 != null}'>${list1}</c:when><c:otherwise>${list2}</c:otherwise></c:choose>" var="element" varStatus="elementStatus">
[+][-]07.05.2008 at 09:46PM PDT, ID: 21939321

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Java Server Pages (JSP), Java Servlets, Java Standard Tag Library (JSTL) & Server Tags
Tags: Java
Sign Up Now!
Solution Provided By: rrz@871311
Participating Experts: 1
Solution Grade: B
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628