protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { User byUsername = userRepo.getByUsername(request.getParameter("id")); if (byUsername != null && byUsername.equals(request.getUserPrincipal())) { request.setAttribute("User", byUsername); this.getServletContext().getRequestDispatcher("/EditUser.jsp").forward(request, response); } }
/** @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String p; if ((p = request.getParameter("delete_username")) != null) { User u = userRepo.getByPK(p); if (u != null && u.equals(request.getUserPrincipal())) { userRepo.deleteUser(u); this.getServletContext().getRequestDispatcher("/users").forward(request, response); } } else if ((p = request.getParameter("save_username")) != null) { User u = userRepo.getByPK(p); if (u != null && u.equals(request.getUserPrincipal())) { u.setEmail(request.getParameter("Email")); u.setWoonplaats(request.getParameter("Woonplaats")); u.setPassword(request.getParameter("Password")); userRepo.saveUser(u); } } else { super.doPost(request, response); } }