title: How to display TABLE dynamically in JSP using SPRING MVC
body: <p>I want to create a table dynamically in such a way that no of headers and data i can pass from JAVA class and on no. basis, jsp should create a table accordingly.</p>
  
  <p>I have controller class in which i am returning model object which is my bean class. In that i have a list attribute in which i have hardcoded some values.These values should be by header names in the JSP table.
  When i am rendering this model object to jsp then i am not able to retrieve the headers info. Plz suggest.
  My contrller class loooks like this:</p>
  
  <pre><code>@RequestMapping
  public ModelAndView getHeaders(PortletRequest portlestRequest, PortletResponse portletResponse){
  
      ModelAndView mv = new ModelAndView();
  
      TableDAO dao = new TableDAO();
      List&lt;String&gt; headersList = dao.getHeaders();
  
      TableView tableView  = new TableView();
  
      tableView.setTableHeaders(headersList);
      mv.addObject("tableView",tableView);
      mv.setView("tableView");
      return mv;
  }
  </code></pre>
  
  <p>My jsp:</p>
  
  <pre><code>&lt;table&gt;
  &lt;c:forEach var = "listValue" items = "${tableView.tableHeaders}"&gt;
      &lt;tr&gt;
        &lt;%for(int i = 0;i&lt;5;i++){ %&gt;
                  &lt;td&gt;
                      &lt;%=${listValue.get(i)} %&gt;
                  &lt;/td&gt;
              &lt;%} %&gt;
      &lt;/tr&gt;
    &lt;/c:forEach&gt;
  &lt;/table&gt; 
  </code></pre>
  
  <p>Someone plz help me on this.</p>