${} is being used by both JSP and JS, so what's happening is that the ${} in the JS template literals are being interpreted and remove before being compiled into servlets. Is there a way I can tell Java to ignore ${} without completely turning the feature off with isELIgnored?
const subject = 'world';
let greet = `hello ${subject}!`
turns into the following in the browser
const subject = 'world';
let greet = `hello !`
Here's the best I've come up with, really not digging how ugly it is though.
<c:out value="var body = `pq_country=${country}&pq_population=${population}`;" escapeXml='false'/>
You can put a backslash in front of the ${} so JSP ignores it (found out through this article by David Ford).
const subject = 'world';
let greet = `hello \${subject}!`
You have to move the JS code to the function inside the external file or script
tag, it would be the best way to solve conflict of jsp with JS syntax.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With