I developed a web in to login from a login.xhtml but I have issues navigating when it validates a user doesn't exist. Rather the page brings out an exception (EJB NoResultException ,getsingle Result()). The application navigates fine when I type the right username and password but it brings the exception page when the user doesn't exist.I am simply trying to achieve that when a user types a wrong password,he is been redirected to the login.xhtml.my code looks like This
//managed bean class
//session scoped
private Admin ad = new Admin();
private String username;
private String password;
//string setters getters
// admin getters, setters
public String login(){
ad= adminEJB.verifyUser(
username,password);
If(ad!=null)
return="welcome";
else return ="login";
}
When I login in with the right username and password ,it navigates to the welcome.xhtml page perfectly but when I test it with a wrong password,it shows me the error page Ejb noresult exception. What could possibly be the problem, I want it to display the login page with a message to say wrong password or invalid account. Also is the idea of using a managedbean to login as sessionscoped the best practice?