I have an issue with a parameter that I'm trying to pass into a Javascript function where the parameter gets cut off.
In my Servlet, I have set a parameter request.setAttribute("questions", service.getQuestions("123"))
It sets a list of questions with each question containing several values;
I loop through them with a JSTL loop <c:forEach var="data" items="${questions}">...</c:forEach>
which I can then access the values as so ${data.question}, ${data.options}
etc.
console.log(${data.question})
returns a value of the form 123,45,35|43,94,73|23,91,34
which is as expected.
But when I try to pass this ${data.question}
into a javascript function such as <script>MyFunction(${data.question})</script>
, it only receives 123
.
MyFunction(data) {
console.log(data); //Only shows 123
//Split the string into arrays for processing
}