JSP getting parameters from servlet
I'm working on a Java web application an开发者_如何学编程d i want my JSP files to comunicate with my Servlets which comunicate with the database.
What is the best way to pass entities i have created from a Servlet to a JSP page?
The standard way to send information from a Servlet to a JSP is to put it in "request scope" using code like this:
List listOfUsers = myDAO.getUsers();
request.setAttribute("users", listOfUsers);
In your JSP, you would retrieve the users object with something like:
<c:forEach var="user" items="users">
User: <c:out value="${user}"/>
</c:forEach>
精彩评论