Allow me to provide an example to make this concept easier to understand!
The jsp file...
<%@ taglib prefix ="jam" uri= "http://jam.tld" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="ISO-8859-1"%>
<%
String targetPage = true ? "toast" : "bread";
%>
<jam:text onmousedown="movePage('<%=targetPage%>');" id="<%=targetPage%>"><%=targetPage%></jam:text>
Note - the taglib mentioned is not of my creation and unfortunately, I do not have any authority over it. (It's not actually named jam either :).
This results in the following HTML output...
<td onmousedown="movePage('<%=targetpage%>;');" id="toast">toast</td>
As you can observe: the <%=targetPage%> was only replaced/parsed outside of the JavaScript section?
The compiled jsp file appears as follows:
jspx_th_jam_005ftext_005f2.setOnmousedown("movePage('<%=targetPage%>')");
Does anyone know what could be causing this issue, or how it can be resolved?
Why is it that the <%=%>
tag seems to be disregarded when included within a JavaScript statement?
:)