title: How to show list of list with dynamic column heading on JSP?
body: <p>Below is my code </p>
  
  <pre><code>    class Entity 
  {
      private int id;
      private String entityName;
  
      private List&lt;Property&gt; 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&lt;Entity&gt; entities = new ArrayList&lt;Entity&gt;();
  
  // ---- 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);
  </code></pre>
  
  <p>I need to show it on JSP as follows </p>
  
  <pre><code>    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
  </code></pre>
  
  <p>The problem I have is each entity has different properties (number of properties and names varies).</p>
  
  <p>I am using JSTL c for each  for iteration. Please help me. </p>
  
  <p><strong>Edit 1:-</strong></p>
  
  <p>For single list i would do something like below.</p>
  
  <pre><code>    &lt;tr&gt;
      &lt;th&gt;Heading 1&lt;/th&gt;
      &lt;th&gt;Heading 2&lt;/th&gt;
      &lt;th&gt;Heading 3&lt;/th&gt;
  &lt;/tr&gt;
  
  
  &lt;tr&gt;
  &lt;c:forEach items="${list}" var="item"&gt;
      &lt;td&gt;${item.property1}&lt;/td&gt;
      &lt;td&gt;${item.property2}&lt;/td&gt;
      &lt;td&gt;${item.property3}&lt;/td&gt;
  &lt;/c:forEach&gt;
  &lt;/tr&gt;
  </code></pre>
  
  <p>If you see above my headings are not in iteration. But in my case i will have my headings in list itself.</p>