0

I can't display a list that was passed as an attribute to my servlet. I followed the JSTL documentation specifications but I didn't get exit, what could be wrong in my code?

My JSP

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>

<c:forEach var="item" items="${lista}">

<ul>
<li>Nome: ${item.getNome()}</li> 
</ul>

</c:forEach>

</body>
</html>

My Servlet

@WebServlet("/listar")
public class ListarUsuariosServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;
    
    
    public ListarUsuariosServlet() {
        super();
    }
          
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws  ServletException, IOException {

        String valor = "2";
        
        List<Usuario> users = UsuarioDAO.getPagination(valor);
    
        RequestDispatcher rd = request.getRequestDispatcher("teste2.jsp");
        request.setAttribute("lista", users);
        rd.forward(request, response);
        
    }

}

0 Answers0