1

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.

Roman C
  • 49,761
  • 33
  • 66
  • 176
star lord
  • 25
  • 5
  • For every other case you've used a `'` followed by a `"`, but for the inner `div` you didn't can you change this `id="check_${response.getJSONObject(index).get("TEMPLATE_ID")}"` to `id='check_${response.getJSONObject(index).get("TEMPLATE_ID")}'`. I think that might solve the issue. – Arun Sudhakaran May 30 '23 at 13:07
  • 1
    @ArunSudhakaran It might, but I'd be surprised *(unless there can be quotes in `TEMPLATE_ID`)*. Here's why: It's a JSP page, so `${response.getJSONObject(index).get("TEMPLATE_ID")}` is evaluated server-side before the browser gets the HTML to render. By the time the client sees it it'll be `id="WHATEVER_TEMPLATE_ID_IS"`, which should be fine *(except for `TEMPLATE_ID` values with quotes)*. – Dave Newton May 30 '23 at 15:03

2 Answers2

0

You're putting a JSTL tag inside the value of an S1 checkbox tag; that won't work.

It needs to be either an S1 expression or a JSP EL expression.

I'd fix it in two ways:

  • Put that data in a better place
    • Don't process it all in the JSP
    • Do the real work on the Java side
    • Simplify the view side
  • Use JSP EL to access the above data
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Dave Newton
  • 158,873
  • 26
  • 254
  • 302
0

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")}' />
                    
Roman C
  • 49,761
  • 33
  • 66
  • 176