Home Struts Hibernate-spring Developing Login Action Class

Related Tutorials


 
 

Share on Google+Share on Google+

Developing Login Action Class

Advertisement
In this section we will explain how to write code for login action class and database code for validating the user against database.

Developing Login Action Class

     

In this section we will explain how to write code for login action class and database code for validating the user against database.

 

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

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

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: December 18, 2008

Related Tutorials

Discuss: Developing Login Action Class   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:2
prashant
November 12, 2011
live tv

not seen any channel on my mobile
Md. Obydul Islam
December 13, 2012
don't understand

your tutorial I can not understand. when I apply this code in my project then error occur springHibernateDAO, checkUserLogin, HttpSession etc. you discuss clear about your code and which place use the code exactly.
DMCA.com