Using JSTL inside Javascript
843840Jan 5 2009 — edited Jan 6 2009Hi,
I am trying to dynamically create html code and insert it into a div tag in my page. The javascript I am using to create the html string is:
function(){
var str="";
str +='<c\:forEach var="statesDetail" items="${statesList}">';
str +='<c\:out value="${statesDetail}"><\/c:out>';
str +='<\/c:forEach>';
code to insert this HTML string to a div tag somewhere in the page-
}
The '\' in the above code is used to escape certain characters. The statesList is an arraylist set in the HttpServletRequest object as an attribute. I can verify that the statesList is not empty. It has 50 entries for all the US states. I loop this list and capture the information using the loop variable statesDetail. I am trying to print the value of statesDetail in the page, but cannot print anything.
If I paste the same code in the page as HTML instead of using javascript to dynamically create it, it works fine. So I am sure something is wrong with the code syntax above. Please help!!!