Reputation:
I'm working on a Java web application and 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?
Upvotes: 2
Views: 935
Reputation: 1508
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>
Upvotes: 5