how to Use <c:forEach> in scripts tag on JSP page?

Hey How to use loop in tag in jsp page?

i want to use JSTL data to pass in data tables

  • When iterating over values, why does typeof(value) return “string” when value is a number? Javascript
  • How can i access index of foreach when iterating through ko.computed in knockout.js
  • What is the difference between 'for…in' and 'for each…in' in javascript?
  • GetElementsByName with array like name
  • Loop Over Array in Javascript
  • For-each over an array in JavaScript?
  • my code is like :

            $(document).ready(function() {
                /* Init DataTables */
                var startString = "[";
                var mainString = "";
                var endString = "]";
                var temp = ${k.size()};
            <c:forEach items="${k}" var="stdn" varStatus="status">
                if (temp === 0) {
                    mainString = mainString + "{key:\"" + "${stdn.key}" + "\",name:\"" + "${}" + "\",rollno:\"" + "${stdn.value.rollNo}" + "\",marks:\"" + "${stdn.value.marks}" + "\"}";
                } else {
                    mainString = mainString + "{key:\"" + "${stdn.key}" + "\",name:\"" + "${}" + "\",rollno:\"" + "${stdn.value.rollNo}" + "\",marks:\"" + "${stdn.value.marks}" + "\"},";
                    var finalString = startString + mainString + endString;
                    var final = eval(finalString);

  • I try to assign an arraylike collection of elements to variables, whats wrong with my code?
  • jQuery.each() in Node.js?
  • jQuery each loop 3-Dimensional Object Array
  • Strange behavior in Javascript enhanced for…in loop
  • Difference between forEach and for loop in javascript
  • Why is native javascript array forEach method significantly slower than the standard for loop?
  • One Solution collect form web for “how to Use <c:forEach> in scripts tag on JSP page?”

    <%@ taglib uri="" prefix="c" %>
    <title><c:forEach>YOUR CODE </title>
    <c:forEach var="i" begin="1" end="5">
       NAME <c:out value="${i}"/><p>

    This would produce following result:

    NAME 1
    NAME 2
    NAME 3
    NAME 4
    NAME 5

    Above is simplest example..
    following is with items var

          <c:forEach var="student" items="${person.person}" varStatus="counter">
              <c:when test="${counter.count % 2 == 0}">
                <c:set var="rowStyle" scope="page" value="odd"/>
                <c:set var="rowStyle" scope="page" value="even"/>
            <tr class="ÃÂ${rowStyle}">

    this way you can use the <c:forEach> </c:forEach> TAG..

    If you have any specific problem then please explain