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 8553951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:46:16+00:00 2026-06-11T14:46:16+00:00

How does one go about printing the values of a nested object/property in a

  • 0

How does one go about printing the values of a nested object/property in a map on a JSP page using JSTL?

<c:foreach items="${survey}" var="survey">
    <c:out value="${survey.value}" />
</c:foreach>

Survey has a property called Questions, which is another bean, and I want to print those questions survey.questions.getId() or survey.questions.getTitle()), how would that <c:forEach> statement look like?

In my case, ${survey} is a Map not a Collection.

  • 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-11T14:46:17+00:00Added an answer on June 11, 2026 at 2:46 pm

    If your nested property is a single object instance, you just reference it directly, like:

    <c:forEach var="surveyItem" items="${surveys}">
        ${surveyItem.title} <!-- You can use the c:out if you really want to -->
    </c:forEach>
    

    That assumes that you have a collection of Survey objects bound to the surveys attribute, and that each Survey has a title. It will print the title of each survey.

    If your nested property is a collection of objects, then you use a forEach loop to iterate them, just like in your example.

    <c:forEach var="question" items="${survey.questions}">
        ${question.title} 
    </c:forEach>
    

    That will print the title of each Question, assuming that you have a single Survey object bound to the survey attribute, and that the Survey object has a collection of Question objects as a field (with an appropriate getter method, i.e. getQuestions()).

    You can also have nested loops, like:

    <c:forEach var="surveyItem" items="${surveys}">
        ${surveyItem.title}
        <c:forEach var="question" items="${surveyItem.questions}">
            ${question.title} 
        </c:forEach>
    </c:forEach>
    

    That will print the title of every Survey along with the title of each Question in each Survey.

    And if for some reason you decide to pass a Map, you can do:

    <c:forEach var="entry" items="${surveyMap}">
        Map Key:  ${entry.key}
        Map Value:  ${entry.value}
        Nested Property:  ${entry.value.title}
        Nested Collection:
        <c:forEach var="question" items="${entry.value.questions}">
            ${question.title}
        </c:forEach>
    </c:forEach>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How does one go about catching exceptions from using controls in markup? For example,
how does one go about counting the amount of a specific object type in
How does one go about properly analyzing the requirements of a client in terms
I was curious as to how does one go about finding undocumented APIs in
In jQuery, how does one go about finding all the 'unchecked' checked boxes. $(':checkbox:checked');
Does any one know about opensource network monitor tool for BlackBerry ?
i am getting this error does some one knows about it??? 2009-07-08 18:42:36.778 FlashCards[1297:20b]
How does one go about 'balancing' a ternary search tree? Most tst implementations don't
How does one go about customizing the GWT user interface that Spring Roo automatically
How does one go about including Google analytics for Trigger.io-built apps? I can see

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.