No End Tag in JSP taglibs

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<td colspan="1" width="100">
<c:choose>
  <c:when>
    <c:choose>
       <c:when></c:when><c:otherwise>
    <c:when test="<%=\"F\".equals(result[1]) %>">
     <c:set var="checked"><%=result[0].equals("Y")%></c:set>
     <input type="checkbox" id="<%="ABC"+"$"+rows%>" name="<%="ABC"+"$"+rows%>" value="<%=String.valueOf(rows)%>" ${checked ? 'checked' : ''} onclick="someFunction(this)"/>
    </c:when></c:otherwise>
    </c:choose>
  </c:when>    
  <c:otherwise>
  </c:otherwise>
</c:choose>
</td>

For some reason, the JSP compiler complains that there is no end tag for the <c:when> that nests the input type="checkbox"...may i know what i'm doing wrong? i tried using <c:if> and it doesnt work either, compiler complains no end tag too.

EDIT: if i dont nest the input type and the set var like below, then it works...but it fails to accomplish my original logic..

    <c:otherwise>
            <c:when test="<%=\"F\".equals(result[1]) %>">
            </c:when>
            <c:set var="checked"><%=result[0].equals("Y")%></c:set>
             <input type="checkbox" id="<%="ABC"+"$"+rows%>" name="<%="ABC"+"$"+rows%>" value="<%=String.valueOf(rows)%>" ${checked ? 'checked' : ''} onclick="someFunction(this)"/>
    </c:otherwise>

EDIT 2: i have to code jsp in this manner on pain of death from my architect lol. any advice will be gladly accepted to retain my proposed logic.

Answers


Just get rid of all those scriptlets (the oldschool <% %> things). They don't mix well with taglibs. The JSTL attributes take EL expressions only.

E.g., assuming that you've done a request.setAttribute("results", results) beforehand, which designtechnically needs to be done in a servlet, but can also be done in a scriptlet somewhere in top of JSP.

<c:forEach items="${results}" var="result">
  ...
  <td colspan="1" width="100">
    <c:choose>
      <c:when>
        <c:choose>
          <c:when></c:when>
          <c:otherwise>
            <c:when test="${result[1] == 'F'}">
              <c:set var="checked">${result[0] == 'Y'}</c:set>
              <input type="checkbox" id="ABC$${rows}" name="ABC$${rows}" value="${rows}" ${checked ? 'checked' : ''} onclick="someFunction(this)" />
            </c:when>
          </c:otherwise>
        </c:choose>
      </c:when>    
      <c:otherwise>
      </c:otherwise>
    </c:choose>
  </td>
  ...
</c:forEach>

It's instantly also much better readable this way.

See also:

Need Your Help

jquery lightbox opening HTML content instead of an image

javascript jquery html lightbox lightbox2

is it possible to open a lightbox window which contains HTML content rather than just an image like in the demos?

How can I display a text box's content when the cursor touches the associated label?

c# .net asp.net asp.net-ajax

I have a label and a text box associated with it. I have added some text in the text box which is invisible at first; I want to display the content after the cursor moves on the label.