Im creating a simple web app using Java EE that takes inputs FirstName and LastName and checks them using database object.
I would like to show a separate error page for these 2 cases :-
1.Only Last Name wrong
2.Both First Name and Last Name wrong
I have build two methods to verify, however I cant figure out the way I should write my if else statements in Servlet.
Currently it is this :-
if(!fullNameTrue){
// show full name wrong error
request.getRequestDispatcher("fullNameWrong.html").forward(request, response);
}
else if(!firstNameTrue){
//show last name wrong error
request.getRequestDispatcher("lastNameWrong.html").forward(request, response);
}
else {
// run the code without error page
User finalUser = getUser(fname,lname);
request.setAttribute("user",finalUser);
request.getRequestDispatcher("displayUser.jsp").forward(request,response);
}
Aucun commentaire:
Enregistrer un commentaire