could you help please?, how I can read the variable objd in a <% … %> Assigned in the foreach?
<c:forEach var="objd" items="${beanDreqproducto}">
<%
Gson j = new Gson();
String data = j.toJson(objd);
%>
console.log("${objd.cantidad}, data: "+'${data}');
</c:forEach>
The
${}basically translates toPageContext#findAttribute(). So, this should do:Note that you should set
datain page scope as well in order to get${data}to work:See also:
Unrelated to the concrete question, this approach is ultimately bad. You should choose to use either JSTL/EL or scriptlets exclusively, not both. If you prefer JSTL/EL, just create a custom EL function to do the desired job, so that you can end up something like as follows:
Our EL wiki page contains a section how to create EL functions.