Hi I am currently passing a string to a servlet which i then search an access database and get a ResultSet object. I convert this to an ArrayList and redirest back to the JSP
I am lookin for a simple piece of c开发者_如何学Pythonode to link to the Servlet to the JSP using a simple link!
I hope this is the correct way of passing a resultset back to the jsp
Use RequestDispatcher#forward()
:
public void doSomething(HttpServletRequest request, HttpServletResponse response) {
List<Item> items = itemDAO.list();
request.setAttribute("items", items);
request.getRequestDispatcher("page.jsp").forward(request, response);
}
JSP example:
<table>
<c:forEach items="${items}" var="item">
<tr>
<td>${item.property1}</td>
<td>${item.property2}</td>
</tr>
</c:forEach>
</table>
Hope this helps.
精彩评论