Tuesday, August 2, 2011

Struts 1.3 Flow


Q1.         Explain the flow of the Struts 1.3?
Ans:      The user fills the fields of the form in a jsp page. The form have action name with default method ‘get’ , This form fields and the form properties  in framework should match each other. Once you completed filling the values in a jsp page and when you click the submit button, the values in a form are stored in a request body with variable names, the request name will be action name of the form. According to the servlet, the request comes to the web.xml file for routing the request. Struts maintain Front Control Design Pattern (FCD),  That means all request comes to the single servlet called ActionServlet given by struts framework. That will be the Controller of the MVC architecture. This class takes the request and Delegates it to RequestProcessor Struts provided class. The name itself indicates that this class will process the request. Here they used Action Controller Design Pattern (AC).This class will process the request as mentioned in the strutsconfig.xml.  First it compares the path name of the action tag and request name. And it matches the name in action tag to the name in the beans. There it verifies the form name. Then the control goes to the Form which extends one Form provided by struts and it creates the object and initializes the request field values to the forms by getter & setter methods. Again the control returns to the strutsconfig.xml file to the same action tag it goes to the Action class which mentioned in actiontag .That Action class must extends one of the Action Class provided by Struts. In Action class having default execute method with four parameters and ActionForward return type. The four parameters are ActionMapping, ActionForm, HttpServletRequest, HttpServletResponse . The Action Form object contains the Values of the fields .From here the business logic will be called and will get the result back with some information. Based on the condition we set the result to the ActionMapping and returning back with ActionForward. Then the controls back to the strutsconfig.xml file where it matches the forward name and redirect to the particular jsp. And this jsp uses some tags provided by struts.Struts 1.3 flow

1 comment: