I have to make a login form for a java project using servlets, MySql and jsp. Everything works fine except that when the username or the password are incorrect the login page should display an error message. I think it' a very simple task but somehow I can't do it, can anybody help me? This is the code in the servlet, and I think it's correct:
if (user != null) {
HttpSession session = request.getSession();
session.setAttribute("user", user);
response.sendRedirect("loginsuccess.jsp");
} else {
request.setAttribute("error", "Attenzione! username o password errati.");
response.sendRedirect("login.jsp");
}
Now I have to create an alert in the login.jsp page displaying this error, what should I do?