-1

I have the following method in servlet

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        request.setAttribute("categories", categoryService.getAll());

        RequestDispatcher dispatcher = request.getRequestDispatcher("/Category.jsp");
        dispatcher.forward(request, response);
        }

and when i call jsp page i want to get all categories from get but it's simply does not call get method

here is my jsp

<body>
<% List<CategoryDTO> categoryList=new ArrayList<CategoryDTO>(); 
categoryList=(ArrayList<CategoryDTO>)request.getAttribute("categories");
%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<c:forEach items="${categoryList}" var="element"> 
  <tr>
    <td>${element.name}</td>

  </tr>
</c:forEach

Can anyone help me please?

joesid
  • 671
  • 1
  • 10
  • 21

1 Answers1

0

No need to declare list in jsp, just try like this ,

<body>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<c:forEach items="${categories}" var="element"> //change here categories not categotyList
  <tr>
    <td>${element.name}</td>

  </tr>
</c:forEach
Jekin Kalariya
  • 3,475
  • 2
  • 20
  • 32