EDIT: I can use the POJO example with the suggested post to output a list of users in the console, but no Object id as shown below. Is that the problem causing output not showing to the JSP page?
User [[email protected], fullName=Didi Dee, password=asdfwle]
User [[email protected], fullName=Lucy Liu, password=lalla]
What I expect the result like below, that show user details under each heading on the browser,
Here is the new method to list user in DAO class
@Override
public List<User> listAll() {
List<User> userList = new ArrayList<User>();
database.getCollection("User", User.class).find().into(userList);
for (User u : userList) {
System.out.println(u.toString());
}
return userList;
}
My service class
public List<User> listUser() {
List<User> userList = userDAO.listAll();
return userList;
}
The Controller
UserService userService = new UserService(request, response);
List<User> userList = userService.listUser();
request.setAttribute("userList", userList); // for jsp to get Attribute
String list_user_page = "user_list.jsp";
RequestDispatcher rd = request.getRequestDispatcher(list_user_page);
rd.forward(request, response);
The JSP to show the output.
<c:forEach items="${userList}" var="user" begin="1">
<tr>
<td>${user.userId}</td>
<td>${user.email}</td>
<td>${user.fullName}</td>
<td><a href="edit_user?id=${user.userId}">Edit</a> <a
href="javascript:void(0);" class="deleteLink" id="${user.userId}">Delete</a>
</td>
</tr>
</c:forEach>

