From f98e86843ff589e151cf7f0046c74a7b6f70eb63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mitja=20Jeseni=C4=8Dnik=20Kotnik?= Date: Fri, 3 Nov 2017 00:37:35 +0100 Subject: [PATCH] list of users in servlet (#2930) --- .../src/main/java/TestEJBServlet.java | 36 +++++++++++++------ 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/ejb/wildfly/widlfly-web/src/main/java/TestEJBServlet.java b/ejb/wildfly/widlfly-web/src/main/java/TestEJBServlet.java index 62feb6b4b9..e86f52ff56 100644 --- a/ejb/wildfly/widlfly-web/src/main/java/TestEJBServlet.java +++ b/ejb/wildfly/widlfly-web/src/main/java/TestEJBServlet.java @@ -1,5 +1,6 @@ import java.io.IOException; +import java.io.PrintWriter; import java.util.List; import javax.ejb.EJB; @@ -15,19 +16,32 @@ import wildfly.beans.UserBeanLocal; * Servlet implementation class TestEJBServlet */ public class TestEJBServlet extends HttpServlet { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - @EJB - private UserBeanLocal userBean; + @EJB + private UserBeanLocal userBean; - protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - List users = userBean.getUsers(); + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + List users = userBean.getUsers(); - response.getWriter() - .append("The number of users is: " + users.size()); - } + PrintWriter out = response.getWriter(); - protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - doGet(request, response); - } + out.println(""); + out.println("Users"); + out.println(""); + out.println("

List of users:

"); + out.println(""); + for (User user : users) { + out.println(""); + out.print(""); + out.print(""); + out.println(""); + } + } + + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + doGet(request, response); + } }
" + user.getUsername() + "" + user.getEmail() + "