Commit 80690381 by Emanuel Lugo

sendRedirect fixed

parent 0c3b6259
...@@ -74,30 +74,21 @@ public class LoginServlet extends HttpServlet { ...@@ -74,30 +74,21 @@ public class LoginServlet extends HttpServlet {
if (target != null){ if (target != null){
response.sendRedirect(target);} response.sendRedirect(target);}
else{ else{
// Si no es posible redireccionar a la pagina solicitada, llevar a la main page
response.sendRedirect("menu.jsp"); response.sendRedirect("menu.jsp");
} }
} }
catch (Exception ignored) { } catch (Exception ignored) { }
// Si no es posible redireccionar a la pagina solicitada, llevar a la main page
/* RequestDispatcher rd = request.getRequestDispatcher("menu.html");
rd.forward(request,response);*/
} else { } else {
//si no es un user valido - mandar error y redireccionar al inicio de sesion //si no es un user valido - mandar error y redireccionar al inicio de sesion
RequestDispatcher rd = request.getRequestDispatcher("/login.jsp");
//out.print("<div br align = \"center\" class=\"messageError\" > Credenciales incorrectas! Reintente ... </div>");
rd.include(request,response);
//response.sendRedirect(request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() +"/login.jsp"); response.sendRedirect(request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() +"/login.jsp");
} }
} }
......
...@@ -31,9 +31,5 @@ public class ProtectedResource extends HttpServlet { ...@@ -31,9 +31,5 @@ public class ProtectedResource extends HttpServlet {
// El usuario se loggeo y puede ver el recurso // El usuario se loggeo y puede ver el recurso
out.println("PUEDES ACCEDER AL RECURSO - ESTAS LOGGEADO"); out.println("PUEDES ACCEDER AL RECURSO - ESTAS LOGGEADO");
} }
} }
\ No newline at end of file
<%@ page import= "jakarta.servlet.http.* , java.lang.Object" %>
<%HttpSession session1 = request.getSession(true);
Object done = session1.getAttribute("logon.isDone");
if (done == null) {
session1.setAttribute("login.target", HttpUtils.getRequestURL(request).toString());
response.sendRedirect(request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() +"/login.jsp");
return;
}%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html> <!DOCTYPE html>
......
<%@ page import= "jakarta.servlet.http.* , java.lang.Object" %>
<%HttpSession session1 = request.getSession(true);
Object done = session1.getAttribute("logon.isDone");
if (done == null) {
session1.setAttribute("login.target", HttpUtils.getRequestURL(request).toString());
response.sendRedirect(request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() +"/login.jsp");
return;
}%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html> <!DOCTYPE html>
......
<%@ page import= "jakarta.servlet.http.* , java.lang.Object" %>
<%HttpSession session1 = request.getSession(true);
Object done = session1.getAttribute("logon.isDone");
if (done == null) {
session1.setAttribute("login.target", HttpUtils.getRequestURL(request).toString());
response.sendRedirect(request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() +"/login.jsp");
return;
}%>
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment