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