In this section we will explain how to write code for login action class and database code for validating the user against database.
In any application the login process is one of the most important task done by the developer. The login action class is responsible for performing success full login. It get the user id and password from the login form and checks the login id and their corresponding password in the database. If matching is found the login action forwarded the action to the home page otherwise it retain the data at the login page with some error.
Following are the necessary steps followed in login process.
Get the login information from the user
Developing Login Action Class
In any application the login process is one of the most important task done by the developer. The login action class is responsible for performing success full login. It get the user id and password from the login form and checks the login id and their corresponding password in the database. If matching is found the login action forwarded the action to the home page otherwise it retain the data at the login page with some error.
Following are the necessary steps followed in login process.
Get the login information from the user
UserLoginForm objForm = (UserLoginForm) form; String strUserid = objForm.getUserid(); String strPassword = objForm.getPassword();
Check the user id and password in the database
boolean loginStatus = springHibernateDAO.checkUserLogin(strUserid, strPassword);
If User id and there corresponding password is matches then add the user Id on the session and check on every pages where security is neccessary
HttpSession session = request.getSession();
session.setAttribute("userID", strUserid);
String id = String.valueOf(springHibernateDAO.getUserId(strUserid));
session.setAttribute("ID", id);
And finally return the success
return mapping.findForward("success");
Following are the views which shows the login process Login form
Returns when User Id or password is incorrect
On correct user id and password the action is forwarded to the home page
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Developing Login Action Class View All Comments
Post your Comment