Just to be clear here. There can be
no direct interaction between JSP and JavaScript. JSP executes on the server in order to format the HTML page containing the JavaScript to be sent to the browser.
What's happening here is that the JavaScript is being dynamically generated. And it must be generated using valid syntax. You can easily see what is being sent to the browser by doing a View Source in the browser.
Those who are unclear on this may find
this article helpful.