title: ArrayList not show in jsp page when used servlet , and DAO
body: <p>I have create Arraylist in DAO and this list used in  servlet. The result of array list shown in jsp page. </p>
  
  <p><strong>DAO</strong></p>
  
  <pre><code>package com.dao;
  
  import com.database.DBConnection;
  import com.mysql.jdbc.Connection;
  import java.sql.PreparedStatement;
  import java.sql.ResultSet;
  import java.sql.SQLException;
  import java.util.ArrayList;
  
  public class ListDAO {
      String status=null;
      Connection con= null;
      PreparedStatement pst=null;
      ResultSet rs = null;
  
      private DBConnection conn;
  
      public ListDAO() {
          con = DBConnection.getConnection();
      }
  
      public  ArrayList&lt;String&gt; getAllUser() throws SQLException {
  
          ArrayList&lt;String&gt; allUser = new ArrayList&lt;String&gt;();
  
          try {
              con = DBConnection.getConnection();
              String queryList = "SELECT name, last_name, zip, phone_no, start_time, end_time, quantity," +
                                 "type, order, logo FROM Database.user_info";
  
              pst = con.prepareStatement(queryList);
  
              rs = pst.executeQuery();
  
                while (rs.next()) {
  
                  allUser .add(rs.getString("name"));
                  allUser .add(rs.getString("last_name"));
                  allUser .add(rs.getString("zip"));
                  allUser .add(rs.getString("phone_no"));
                  allUser .add(rs.getString("start_time"));
                  allUser .add(rs.getString("end_time"));
                  allUser .add(rs.getString("quantity"));
                  allUser .add(rs.getString("type"));
                  allUser .add(rs.getString("order"));
                  allUser .add(rs.getString("logo"));
              }
          }
          catch (SQLException e) {
              e.printStackTrace();
          } 
          finally {
              if(rs!=null) {
                  try {
                      rs.close();
                  } catch(SQLException logOrIgnore) {}
              }
              if(pst!=null) {
                  try {
                      pst.close();
                  } catch (SQLException logOrIgnore) {}
              }
              if(con!=null) {
                  try {
                      con.close();
                  } catch(SQLException logOrIgnore) {}
              }
          }
          return allUser;
      }
  }
  </code></pre>
  
  <p>This arraylist pass in the servlet which given below:</p>
  
  <p><strong>Servlet</strong></p>
  
  <pre><code>package com.servlet;
  
  import com.dao.ListDAO;
  import com.database.DBConnection;
  import com.mysql.jdbc.Connection;
  import java.io.IOException;
  import java.io.PrintWriter;
  import java.sql.SQLException;
  import java.util.ArrayList;
  import javax.servlet.ServletException;
  import javax.servlet.annotation.WebServlet;
  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  import javax.servlet.http.HttpSession;
  
  @WebServlet("/checkLogin")
  public class LoginServlet extends HttpServlet {
  
      Connection con= null;
  
      @Override
      protected void doGet(HttpServletRequest request, HttpServletResponse response) 
              throws ServletException, IOException {
  
  
          ListDAO Vendors = new ListDAO();
  
          if(!userValidate.equals("FALSE")) {
  
                 //Login verified user
  
              try {
                  con = DBConnection.getConnection();
              ArrayList&lt;String&gt; allUser = Vendors.getAllUser();
  
              request.setAttribute("allUser", allUser); // Will be available as ${allUser} in JSP
              System.out.println(allUser);
              request.getRequestDispatcher("userProfile.jsp").forward(request, response);
              }
              catch (SQLException ex) {
                throw new ServletException("Cannot obtain allUser from Database", ex);
              }     
          }
          else {
                 response.sendRedirect("login.jsp");
          }
      }
  }
  </code></pre>
  
  <p>And the userProfile.jsp page in which i want to show the ArrayList which is given below:</p>
  
  <pre><code>&lt;c:forEach var="user" items="${allUser}"&gt;
      &lt;div class="col-md-5"&gt;
            &lt;img src="Resources/images/logo/logo1.jpg" alt="Logo1"&gt;
            &lt;h2&gt;${user.name} ${user.last_name}&lt;/h2&gt;
            &lt;p&gt;${user.zip}, ${user.phone_no}, ${user.start_time}, ${user.end_time}&lt;/p&gt;
            &lt;p&gt;${user.quantity}, ${user.type}, ${user.order}, ${user.logo}&lt;/p&gt;
      &lt;/div&gt;
  &lt;/c:forEach&gt;
  </code></pre>
  
  <p>The problem is that the whole Array List is in single array, that's why problem to show the array in jsp page. I want to display the individual record of each user(each have 10 thing to display) separately. Can anyone tell me at which place I have did wrong thing.</p>
  
  <p>Thanks!</p>