I'm newer in java. I need to iterate the news type in jsp page. I use <c:foreach>
to do than in jsp page. In javaee Eclipse IDE I create a servlet to respose to jsp page. And create a newstype class in java to get and set newsid and newsname. Then in jsp loop newsid and newsname, code like:
<ul>
<c:forEach var="type" items="${types}">
<li><a href="#"><c:out value="${type.typeName}"/></a></li>
</c:forEach>
</ul>
There is the servlet code:
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
newsservice ns = new newsservice();
Map<Integer,String> types = ns.getNewsType();
request.setAttribute("types",types);
request.getRequestDispatcher("/jsp/index.jsp").forward(request, response);
}
But open jsp page in chrome I got nothing. I'm concerned I'm do something wrong connect servlet and jsp, and miss something in code. Please somebody finger out. I'm sure import the taglib:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
This is the snapshot: newspage project