I have implemented that method, which should be redirected to the personal page if the data and users with data in the database ID is successfully received, but if it is empty it must be redirected to the login page. How can handle empty exceptions in this method? The logged in for the logged in filter requires attention and thanks for your help!
get public strings (user) (UserDao ud = new UserDao); SessionBean.setCurrentUser (ud.getSessionUserFromDb (Input Login, InputPassword)); Try {currentUserId = sessionBean.getCurrentUser () GetUserId (); } Hold (NullPointerException e) {System.out.print ("NullPointerException caught"); } If (currentUserId! = 0) {loggedIn = true; If (login = true) {System.out.println ("successfully logged in");} Return session bn.directPoseral (); } Else {FacesMessage msg = New FacesMessage ("Login Error!", "Error MSG"); Msg.setSeverity (FacesMessage.SEVERITY_ERROR); FacesContext.getCurrentInstance (). AddMessage (null, msg); Return session Bean.redirectToLogin (); }}
should do this:
If (sessionBean.getCurrentUser ()! = Null) {currentUserId = sessionBean.getCurrentUser (). GetUserId ()} and {System.out.println ("The current user is empty!"); }
No comments:
Post a Comment