title: How to display data from collections in JSP
body: <p>I have a Java Bean as Below</p>
  
  <pre><code>  class Account 
    {
       private long id;
       private String userName;
       private String userId;
  
       //Getters, Setters for Above 
    }
  
     public List&lt;Account&gt; getAccountList()
     {    
        List&lt;Account&gt; accountList = new ArrayList();
  
        Account account;
  
        .
        .
        .
        //db code for fetching data's from database
  
        while(rs.next()) 
        {       
           account = new Account();
  
           account.setId(rs.getLong("Id"));
           account.setUserName(rs.getString("UserName"));
           account.setUserId(rs.getString("UserId"));
  
           accountList.add(account);
        }
  
        return accountList ;
    }
  </code></pre>
  
  <p>I am Assigning the List which I got in the function in a servlet and I am forwarding it to JSP page where I will display List of Users in Account.</p>
  
  <pre><code>List&lt;Account&gt; accountList = new ArrayList&lt;Account&gt;();
  accountList = objdbUtil.getAccountList();
  request.setAttribute("arrUsersList", accountList);          
  RequestDispatcher rdst =  request.getRequestDispatcher("UserList.jsp");
  rdst.forward(request, response);
  </code></pre>
  
  <p>Now how to display the Data's in JSP as the List contains collections in it. </p>
  
  <p>Can I directly use below code</p>
  
  <pre><code>&lt;c:forEach var="arrUsersList" items="${requestScope.arrUsersList}"&gt;
  &lt;/c:forEach&gt;
  </code></pre>