From f022c7de4e56ed66e9cf9b137a3e9311283855e1 Mon Sep 17 00:00:00 2001 From: aqpcalel <40297662+aqpcalel@users.noreply.github.com> Date: Sat, 16 Jun 2018 00:42:55 -0500 Subject: [PATCH] Update ResourcesControllerIndex.java --- .../resources/ResourcesControllerIndex.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/controller/resources/ResourcesControllerIndex.java b/src/controller/resources/ResourcesControllerIndex.java index 29e617b..b0b1836 100644 --- a/src/controller/resources/ResourcesControllerIndex.java +++ b/src/controller/resources/ResourcesControllerIndex.java @@ -1,15 +1,41 @@ package controller.resources; +import controller.users.UsersControllerView; +import model.User; + +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 javax.servlet.http.HttpSession; import java.io.IOException; @SuppressWarnings("serial") public class ResourcesControllerIndex extends HttpServlet { protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + + //Se usa para revisar si hay una sesion activa + HttpSession sesion= request.getSession(); + //Intenta hallar una sesion activa + try{ + User user = UsersControllerView.getUser(sesion.getAttribute("userID").toString()); + if (user == null) throw new NullPointerException("UsersControllerIndex: El usuario recibido es nulo."); + + request.setAttribute("User",user); + request.setAttribute("ResourceList",RolesControllerView.getAllRoles()); + RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/View/Resource/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 {