views:

36

answers:

3

I have this code:

<c:forEach var="product" items="${products}" begin="${begin}" end="${end}" varStatus="loopStatus" step="1">
    <div class="home_app "${loopStatus.index % 2 == 0 ? '' : 'white_bg'}">

When I browse to the jsp I am getting this in the div:

<div }="" white_bg="" :="" ?="" 0="" 2="=" %="" ${loopstatus.index="" class="home_app ">
+1  A: 

The " before the dollar sign seems to be at the wrong place. Remove it.

vanje
Done that still not working.
arinte
Is the output still the same?
vanje
It's not relevant for EL so no, this won't help anything.
BalusC
+1  A: 

Try this (change in bold):

<c:forEach var="product"
           items="${products}"
           begin="${begin}"
           end="${end}"
           varStatus="loopStatus"
           step="1">
    <div class="${loopStatus.index % 2 == 0 ? '' : 'white_bg'}">

My personal preference is the following instead of the ?: operator:

<c:choose>
    <c:when test="${(loopStatus.index % 2) == 1}">
        <div>
    </c:when>
    <c:otherwise>
        <div class="white_bg">
    </c:otherwise>
</c:choose>
dwb
+1  A: 

The conditional operator (and EL in template text) was introduced in JSP 2.0. Chances are that you're running a servletconainer which doesn't support JSP 2.0 or is declaring web.xml as Servlet 2.2 or older.

BalusC
sucks. I don't know why they never made an attempt to update this server...
arinte