0

I have a jstl array with,

<sql:query var="list_str" dataSource="${myDS}">
    SELECT * FROM str;
</sql:query>

Now i want to fill a single column content of the table str in a javascript array. I am trying this.

<c:forEach items="${list_str.rows}" var="user" varStatus="status">
    var val = ${user.Name};
    fruits.push(val);
</c:forEach> 

But, the fruits array value is empty, can anyone please guide how to accomplish this.

2
  • Did you have a look a the generated client-side source code? Commented Sep 10, 2014 at 15:29
  • var val= <c:out value="${user.Name}"/> Commented Sep 10, 2014 at 16:08

1 Answer 1

1

You don't need the var val and you need quotes around what will become a hard-coded string literal in the resulting javascript code.

<c:forEach items="${list_str.rows}" var="user" varStatus="status">
    fruits.push('${user.Name}');
</c:forEach>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.