Struts 1.2/1.3 :
In the bellow code sample I tried to show a simple login and registration system.Struts framework was used for implementing MVC. For Persistence layer implementation i used the Hibernate.
First Let us see Implementation of MVC using Struts framework.
Here for the view part of the MVC i am using loginForm. jsp, loginSuccessful.jsp, loginCancel.jsp ,loginFailed.jsp , logout.jsp as a part of login process and SignUp.jsp , SignUpSuccessful.jsp ,& signUpCancel.jsp for SignUP/Registration process.
Here i would like to say one important point , From the Software Systems point of view we say SignUp as a process of User Authentication and the login as a process of user Authorization.
Bellow i am listing out the code for all the above said view's first all SignUp process related views and followed by all login related view. Here the point is in order to do login one must have done SignUp first .
Out put image of SignUp.jsp
SignUp.jsp source code:
SignUpSuccessful.jsp ,& signUpCancel.jsp source code are very simple i am not displaying them if you want you can download the entire project code sample from the code samples tab.
Out put image i loginForm.jsp
Source Code for loginForm.jsp
Struts Configuration File: struts-config.xml
Code of Properties File:
Source Code for SignUpFormBean:
Source code for SignUpAction
Source Code for LoginFromBean:
Source Code for LoginAction
Business logic regading to the login process is seperated in to LoginBO.To get the benifits of loose coupling i used iLoginBO interface and it is implemented in LoginBOimpl class. Following is the code for iLoginBO
iLoginBO Source Code
LoginBOimpl Code
Persistance logic is seperated through DAO pattern
Bellow is the code for LoginDAO
Bellow is the code for SignUpDAO
I used Hibernate to persist the objects.(Persistence means making the data as permanent data by storing data onto permanent storage like hard disk).
For more details about persisting objects using Hibernate please see my another code sample Struts-Hibernate Integration.
For technical support please contact me at
murali@javamission.com
|