0
I log in to my jsp, so I have Servlet do the checks, and return to jsp, but returning the url continues with the Servlet path, and not with my index.jsp follows part of the code that returns to my jsp.
try {
System.out.println("esta no ServletLogin");
loginUsuario = new UsuarioService().verificaLoginUsuario(emailUsuario);
if(loginUsuario == true){
loginSenhaUsuario = new UsuarioService().verificaSenhaUsuario(emailUsuario, senhaUsuario);
if(loginSenhaUsuario == true){
usuario = new UsuarioService().getUsuario(emailUsuario);
request.getSession().setAttribute("emailUsuario", emailUsuario);
request.getSession().setAttribute("nomeUsuario", usuario.getNome());;
System.out.println("anteslogado");
response.sendRedirect("index.jsp");
System.out.println("logado");
}else{
System.out.println("senha diferente");
}
}else{
System.out.println("nao existe esse usuario");
}
} catch (ClassNotFoundException | SQLException e) {
System.out.println("não deu pra verificar");
}
}
Servlet responds to the login but then is not giving the redirect, is that it? And no log appears on the server?
– Giuliana Bezerra
This, makes the login all right, the redirect sends to the login screen, but the url continues in Servletlogin, does not go back to index, so it happens that some scripts in my index do not load, so I need you to change the url
– henrique klock
I’ll kick, try using foward (request.getRequestDispatcher(<colocaonomedajspaqui>). forward(request, Response)).
– Giuliana Bezerra
foward itself is that it does not change url, sendRedirect would have to change, I did some tests and saw that when I log in the url is in Servlet, so when I update this page of Servlet, the url goes to the index, doing what I should have done the first time, without needing to update the page, I put some sysout on my page, to see if it was entering some part of the code at first tempting, but enter all right, you know what would be this?
– henrique klock
If you have reached Servlet it is because it is not redirecting to the page correctly. Which directory is index.jsp in? It is also good to check if this Servlet answers the index.jsp page (it is in the urlPatterns). If you have to handle the return to the same page.
– Giuliana Bezerra