I have a servlet class for login process, if the username or password is incorrect I want to set two attributes to the request, one attribute is boolean authentication_error
, the second is string authentication_error_message
.
I want to make a condition statement to print the authentication_error_message
if the authentication_error
is true.
req.setAttribute("authentication_error", false);
if(!query.list().isEmpty()){
List<?> list = query.list();
Admin student = (Admin)list.get(0);
req.setAttribute("username", student.getUsername());
}
else{
req.setAttribute("authentication_error_message", "username or password is incorrect!");
req.setAttribute("authentication_error", true);
}
req.getRequestDispatcher("/views/login.jsp").forward(req, res);
How I can write this statement in jsp?
N.B: preferr to not use jstl.