Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Using JSTL inside Javascript

843840Jan 5 2009 — edited Jan 6 2009
Hi,

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!!!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 3 2009
Added on Jan 5 2009
6 comments
8,601 views