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

  • Home
  • SEARCH
  • 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 6738213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:20:24+00:00 2026-05-26T11:20:24+00:00

Below is my code class Entity { private int id; private String entityName; private

  • 0

Below is my code

    class Entity 
{
    private int id;
    private String entityName;

    private List<Property> properties;

    // other properties and getters and setters
}

class Property 
{
    private int id;
    private String propertyName;
    private String propertyValue;

    // other properties and getters and setters
}


List<Entity> entities = new ArrayList<Entity>();

// ---- Entity 1
Entity entity1= new Entity();
entity1 . setEntityName("Person");

Property property1 = new Property();
property1 .setPropertyName("FirstName");
property1 .setPropertyValue("Peter");


Property property2 = new Property();
property2 .setPropertyName("LastName");
property2 .setPropertyValue("Pan");

Property property3 = new Property();
property3 .setPropertyName("Age");
property3 .setPropertyValue("28");


entity1.getProperties().add(property1);
entity1.getProperties().add(property2);
entity1.getProperties().add(property3);

entities.add(entity1);

// ---- Entity 2
Entity entity2= new Entity();
entity2 . setEntityName("Location");

Property property1 = new Property();
property1 .setPropertyName("Address");
property1 .setPropertyValue("302 New york Street");


Property property2 = new Property();
property2 .setPropertyName("City");
property2 .setPropertyValue("New york");


Property property3 = new Property();
property3 .setPropertyName("Country");
property3 .setPropertyValue("US");

entity2.getProperties().add(property1);
entity2.getProperties().add(property2);
entity2.getProperties().add(property3);

entities.add(entity2);

I need to show it on JSP as follows

    Person 

    Firstname       LastName        Age

    Peter           Pan             28
    Van             helsing         50
    Tom             Williamson      35


    Location

    Address                 City            Country

    302 New York Street     New York        US
    Highway Street          Londona         UK

The problem I have is each entity has different properties (number of properties and names varies).

I am using JSTL c for each for iteration. Please help me.

Edit 1:-

For single list i would do something like below.

    <tr>
    <th>Heading 1</th>
    <th>Heading 2</th>
    <th>Heading 3</th>
</tr>


<tr>
<c:forEach items="${list}" var="item">
    <td>${item.property1}</td>
    <td>${item.property2}</td>
    <td>${item.property3}</td>
</c:forEach>
</tr>

If you see above my headings are not in iteration. But in my case i will have my headings in list itself.

  • 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-05-26T11:20:25+00:00Added an answer on May 26, 2026 at 11:20 am

    As long as the entities are already grouped by their “type”, just take the first item in the collection, iterate over its properties, and display the property names.

    Then iterate over the entire entity list, displaying only each entity’s property values.

    If they’re not already grouped by entity “type”, then you’ll need to sort them by entityName, and follow the same procedure as above. The only difference would be that as you iterate over the entities you must track of the previous entity’s type. When the current entity’s type is different than the previous entity’s type, display the new headings and continue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the below code ArrayList<String> city = 'Anniston'; Criteria crit = session.createCriteria(CandidateResumeInfo.class); crit.add(Restrictions.eq(resumeSearchable,
In the demo code below, the User is the parent entity, with a one-to-many
In the code below I can get the class name via: s.__class__.__name__ #Seq but
I have a class with many properties, one of them are byte[] property. I
When running the below code a type is never returned, despite there being a
In the below code snippet can i replace char * to const char *
I have the below code in stdafx.h. using namespace std; typedef struct { DWORD
In the below code sample, what does {0:X2} mean? This is from the reflection
In the below code, the ListBox gets filled with the names of the colors
I would like to know how to modify the below code to strip =20

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.