Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8370409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:54:18+00:00 2026-06-09T13:54:18+00:00

Hello all I have a bean that has 3 getters. In the JSP I

  • 0

Hello all I have a bean that has 3 getters. In the JSP I use JSTL to iterate over the bean to populate a table. I have saome javascript I need to do the same thing to construct an array. Here it is hardcoded, but how can I contruct it by itearing over a bean?

Bean: This is how I do it in the JSP using JSTL

<c:forEach var="bean" items="${beans}">
     ${bean.month}       
     </c:forEach>

How Can I do the same thing here:

Javascript:

"categories": [{
    "category": [{
       "label": "Oct"
    }, {
        "label": "Nov"
    }, {
        "label": "Dec"
    }, {
       "label": "Jan"
    }, {
        "label": "Feb"
    }, {
        "label": "Mar"
    }, {
        "label": "Apr"
    }, {
        "label": "May"
    }, {
        "label": "Jun"
    }, {
        "label": "Jul"
    }, {
        "label": "Aug"
    }, {
        "label": "Sep"
    }]     
    }]

Trying to do something like this in javascript

 <c:forEach var="bean" items="${beans}">
     [{
       "label": " ${bean.month}"
    },         
     </c:forEach>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T13:54:19+00:00Added an answer on June 9, 2026 at 1:54 pm

    I am not well experienced in JSTL. This is a guess based on the experience I have in PHP.

    var array = [
    <c:forEach var="bean" items="${beans}" varStatus="beanStatus">
        {
            "label": "${bean.month}"
        }
        <c:if test="${!beanStatus.last}">  // put comma after all item, but last one
             ,
        </c:if>          
     </c:forEach>
    ];
    

    or

    var array = [];
    <c:forEach var="bean" items="${beans}">
        array.push({
            "label": "${bean.month}"
        });         
    </c:forEach>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hello all I have a small dialog which I created dynamically, which has a
hello all this seems to be my problem I have a table in mysql
Hello all does anyone know if it's possible or that the UITableviewcells have a
Hello All I am using infragsitics tree view control.I have one stored procedure that
hello all i have code from open source project that im integrating into my
Hello all I have class that inherited from Qtreeview and I implement simple (
Hello all I have a table comment as follows commentid cmt followupid category 1
hello all i am working on a project in which i have a webpage
Problem Hello all! I have this code which takes my jpg image loops through
Hello I currently have this code checking if a cookie exists, it works all

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.