开发者

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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜