title: How to iterate through list of objects in jsp
body: <p>Hi friends i am trying iterate through a list that contains list of objects
  I am trying to iterate through that list . each element of the list is a 'object'. 
  I accessing the variables of that 'object' with the help of c:forEach . I am getting the values. but the same again and again . 
  I dont know if i am doing any mistake while adding objects to list in the servlet or in the jsp while iterating through them.</p>
  
  <p>Here is my servlet code </p>
  
  <pre><code>FileInfo fileInfo = new FileInfo();
              List&lt;FileInfo&gt; fileInfoList = new ArrayList&lt;FileInfo&gt;();
  
              HashMap&lt;String, String&gt; uploadHistory = new HashMap&lt;String, String&gt;();
  
              while(rs.next()) {
  
                  fileInfo.setFile_id(rs.getString("file_id"));
                  fileInfo.setFile_name(rs.getString("file_name"));
                  fileInfo.setUpload_time(rs.getString("upload_time"));
                  fileInfo.setUsername(rs.getString("username"));     
  
                  fileInfoList.add(fileInfo);
  
                  uploadHistory.put(rs.getString("file_name"),rs.getString("upload_time"));
              }
  
              request.setAttribute("uploadHistory",uploadHistory);
              request.setAttribute("fileInfo",fileInfo);
              request.setAttribute("fileInfoList", fileInfoList);
              RequestDispatcher rd = request.getRequestDispatcher("/UploadHistoryJsp");
              rd.forward(request, response);
  </code></pre>
  
  <p>Here is my jsp</p>
  
  <pre><code>&lt;div class="panel-body"&gt;
                      &lt;table id="uploadHistoryTable" class="table"&gt;
                          &lt;thead&gt;
                              &lt;tr&gt;
                              &lt;th&gt;&lt;strong&gt;File Name&lt;/strong&gt;&lt;/th&gt;
                              &lt;th&gt;&lt;strong&gt;Date &amp; Time&lt;/strong&gt;&lt;/th&gt;
                              &lt;/tr&gt;
                          &lt;/thead&gt;
  
                          &lt;tbody&gt;
  
                              &lt;c:forEach var="uploaded" items="${fileInfoList}"&gt;
                              &lt;tr&gt;
  
                                  &lt;td&gt;&lt;a href="${pageContext.request.contextPath}/DownloadServlet?f=${uploaded.file_name}&amp;p=${uploaded.username}"&gt;${uploaded.file_name}&lt;/a&gt;&lt;/td&gt;
                                  &lt;td&gt;${uploaded.upload_time}&lt;/td&gt;
                              &lt;/tr&gt;
                              &lt;/c:forEach&gt;
                          &lt;/tbody&gt;
                      &lt;/table&gt;
  
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;&lt;!-- panel-body --&gt;
  </code></pre>
  
  <p>Please help . Sorry for any confusion.</p>