Authentication mechanism allows users to have secure access to the application by validating the username and password. Step 5: Now create the Login DAO java class as below.
We will be using JSF view for login, DAO object , Http Session for session management, JSF managed bean and mysql database. Note that database operations code is not optimized to be used in a real project, I wrote it as quickly as possible because the idea is to learn authentication in JSF applications.
Then compare with the password that you got from html page and the password from the query If the above is not working out, I recommend you to keep the presentation(view) in JSP, validation in a servlet.
If not, then you know the user/password combination is wrong.
You should not just fetch all the users into your Java code and compare them.
You're hauling the entire DB table into Java's memory and comparing every single row against the input. You're not understanding/utilizing the powers of the SQL language.
You should write SQL queries in such way that it returns exactly the data you're looking for.
I'm going to guess that you'll find the problem is in the line: Hi Joseph When you are declaring/writing in JSP scriplet that translated in service method while JSP to servlet translation.