From 819db70af4bcfcf9eb4d71f931e37fc1d68825d0 Mon Sep 17 00:00:00 2001 From: Araozu Date: Thu, 14 Jun 2018 21:07:38 -0500 Subject: [PATCH] Funcionalidad basica completa. --- .../users/UsersControllerIndex.java | 36 ++++++++++++++++--- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/src/controller/users/UsersControllerIndex.java b/src/controller/users/UsersControllerIndex.java index 036c853..6077dfd 100644 --- a/src/controller/users/UsersControllerIndex.java +++ b/src/controller/users/UsersControllerIndex.java @@ -1,18 +1,44 @@ package controller.users; +import java.io.IOException; +import java.io.PrintWriter; + +import javax.jdo.PersistenceManager; +import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import java.io.IOException; +import javax.servlet.http.HttpSession; + +import com.google.appengine.api.users.User; +import com.google.appengine.api.users.UserService; +import com.google.appengine.api.users.UserServiceFactory; @SuppressWarnings("serial") public class UsersControllerIndex extends HttpServlet { - protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException { + + //Se usa para revisar si hay nua sesion activa + HttpSession sesion= request.getSession(); + PersistenceManager pm = controller.PMF.get().getPersistenceManager(); + + //Intenta hallar una sesion activa + try{ + request.setAttribute("User",UsersControllerView.getUser(sesion.getAttribute("userID").toString())); + request.setAttribute("UsersList",UsersControllerView.getAllUsers()); + RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/View/Users/index.jsp"); + dispatcher.forward(request,response); + } + //Si no la encuentra, redirige a la pagina inicial. + catch (Exception e){ + e.printStackTrace(); + response.getWriter().println(""); + } } - protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - + public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { + doPost(request, response); } -} +} \ No newline at end of file