Struts architecture Example
- In the above web application business logic is directly keep in execute (-,-,-) of Actionclass. So Actionclass itself is called as Model
- Every form bean class object is visible in associated Actionclass as the parameter of execute method. So that the execute method can use form data as input values while executing the business logic
- Execute(-,-,-) is a fixed method in struts Actionclass which can contain either business logic directly or it can contain logic to communicate with other model component like ejb components, spring app and etc
- With respect to the diagram
- 1
- End-user launches form pages on the browser window, by filling up the form and send the request
- 2
- Based on the configuration done in web.xml file the ActionServlet traps (catches) and takes the request given by the browser window
- 3
- ActionServlet uses struts config file to decide appropriate form bean & Actionclass that have to be used to process the request
- 4
- ActionServlet creates or locates formbean class object and writes form data to it which is received from form page
- 5
- ActionServlet creates or locates Actionclass object and calls execute(-,-,-) on that object
- 6
- business logic of Actionclass executes and generates the result
- 7
- Actionclass sends business logic execution results to controller servlet called ActionServlet
- 8
- ActionServlet uses ActionForward config of struts configuration file belonging to Actionclass
- 9
- ActionServlet forwards the control to result page to format the result
- 10
- result page uses presentation logic format for the result and sends format of result to browser in the form of dynamic web pages