Struts is MVC based framework developed by Apache. Framework generally provides the basic functionality for a project. Struts provides the set of Action classes, set of tag-libraries, set of Form beans and etc.
Struts combines the most of the design patterns in to a single framework. Struts implements the Single-ton design pattern, Delegate design pattern, Factory Design pattern, Chain of responsibilities.
Struts is Strongly Model View Controller (MVC)based framework MVC fallows the three tier architecture. The model, view and controllers regarding to the Struts are explained as fallows.
View is used to show something to user. Struts allows to use htmls, jsps as view components. To develop the more friendly views struts provided the set of tag libraries. You can download these libraries from the apache site and you can use those into your view components. The set of tag libraries are
struts-html : These tags are replacement of normal html tags. The struts html tags are binds with the form bean properties.
Ex: <html:text property=”userName” />
tag replaces the normal html tag like
<input type=”text” name=”userName” />
struts-bean : These tags are replacement for the jsp action tags. The bean properties are defined with this tags, you can get the bean properties using struts-bean tags.
Ex: <bean:define id=”tempVar” value=”10” />
Above tag defines a variable as ‘tempVar’ and assign 10 to it as string value.
<bean:write name=”Employee” property=”empId” />
Above tag get the value of empId from the Employee form bean.
Struts-logic: These tags are used to write the logical operations. To validate the if conditions or equals conditions you can use these tags.
Ex: <logic:equal name=”empId” value=”100” >Adimin</logic:equal>
Admin is displayed when the empId equals to 100 only.
To get the for loop type iterations you can use the <logic:iterate /> tag.
struts-nested: To display the group of objects you can use the nested tags.
You can implement most of the functionality of above three tags with the nested tags.
Inplace of <bean:write /> you have <nested:write /> and so on…….
Business logic and persistence logic (database dependent logic) will be developed in Model. In struts you can use normal Java beans, DTOs, Dos as models. You can develop the Model layer using other tools also. Struts allows to use Hibernate, spring in the model layer.
Controller is most important concept in the Struts 1.3. In struts ActionServlet acts as Front controller. Each and every request must passes through the ActionServlet. You can change the ActionServlet functionality by extending ActionServlet to your own class.
RequestProcessor class also acts as the controller to process the request. In struts 1.3 Request processor is the ComposableRequestProcessor. It has processXXX() methods. These methods are controls the execution of action classes, controlling of form beans ..etc.
Actions, Dispatch actions, Action Forms , Validator forms ..etc all are come under the controller.