Search code examples
jspjstlstrutsstruts-1struts-tags

org.apache.jasper.JasperException: "equal symbol expected" when using JSTL c:out as value of Struts1 html:checkbox


I am using JSTL and Struts1 and I am getting

org.apache.jasper.JasperException: "equal symbol expected"

on the line with <html:checkbox>:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="html" uri="http://struts.apache.org/tags-html"%>
<c:forEach begin="0" end="${response.length() -1}" var="index">
    <tr class=""  onClick="myFunction('${response.getJSONObject(index).get("TEMPLATE_ID")}', '${response.getJSONObject(index).getString("TEMPLATE_NAME")}')">
        <td class="break-word">
            <div class="checkbox-inline">
                <div class="chkbox icheckbox_minimal hover" id="check_${response.getJSONObject(index).get("TEMPLATE_ID")}" >
                    <html:checkbox styleClass="iCheck-helper" 
                            style="position: absolute; opacity: 0;" 
                            property="orchTempList" 
                            value="<c:out value='${response.getJSONObject(index).get("TEMPLATE_ID")}'/>" />
                    <ins class="iCheck-helper" 
                            style="position: absolute; top: 0%; left: 0%; display: block; width: 100%; height: 100%; margin: 0px; padding: 0px; background: rgb(255, 255, 255); border: 0px; opacity: 0;" ></ins>
                </div>
                ${response.getJSONObject(index).getString("TEMPLATE_NAME")}
            </div>
        </td>
    </tr>
</c:forEach> 

Here the ${response} is a JsonArray.


Solution

  • You can't use JSTL tags inside the Struts tag's attribute. But you can change the code just by replacing <c:out> with JSP EL expression.

    It is not related but you should know that it works if you nest double quotes in the tag, but the JSP editor can show the error, so you could replace nesting double quotes to single quotes. JSP allows to use single quotes for attributes. For better explanation of the problem you should read this question: Simple error due to use of double quotes in a JSP file.

    Change the code:

    <html:checkbox styleClass="iCheck-helper" 
                                style="position: absolute; opacity: 0;" 
                                property="orchTempList" 
                                value='${response.getJSONObject(index).get("TEMPLATE_ID")}' />