When we deploy our application in the server, at first the container reads the information from web.xml file.Here ActionServlet object will be created and init() of ActionServlet will be called.Here ActionServlet is the backbone to the whole application.
When client send a rewuest using .jsp extension , getters() and reset() of FormBean will be called. When client fill the form and press on submit button, then setters() and validate() will be called. If the data is not valid ,then the form redirects to another page which is specified in struts-config.xml file. If the data is valid , then only Action class object will be created.
In Action class , have execute() which have return type of ActionForward. We can specify the business logic in Model and provide that object in execute(). After completion of business logic execution , then it forwards to another page ( either success or failure) , whichis specified in struts-config.xml file.
A client requests a path that matches the Action URI pattern.The container passes the request to the ActionServlet.If this is a modular application, the ActionServlet selects the appropriate module.The ActionServlet looks up the mapping for the path.If the mapping specifies a form bean, the ActionServlet sees if there is one already or creates one.If a form bean is in play, the ActionServlet resets and populates it from the HTTP request.If the mapping has the validate property set to true, it calls validate on the form bean.If it fails, the servlet forwards to the path specified by the input property and this control flow ends.If the mapping specifies an Action type, it is reused if it already exists or instantiated.The Action’s perform or execute method is called and passed the instantiated form bean (or null).The Action may populate the form bean, call business objects, and do whatever else is needed. The Action returns an ActionForward to the ActionServlet.If the ActionForward is to another Action URI, we begin again; otherwise, it’s off to a display page or some other resource. Most often, it is a JSP, in which case Jasper, or the equivalent (not Struts), renders the page.
Flow:: 1) Action servlet gets the request.It initiates the servlet-config.xml and selects an appropriate page as per the mapping 2)If the accessed file is .java it does the appropriate action and fwd it to the file specified in the strus-config.xml. If the accessed path is .jsp it invokes the action bean where in the validation for the user input is done,if it fails errors are displayed..if it succeeds the action servlet is kicked and does the steps in execute() method..and fwd it to the necessary page as in mappings.foward()
The Struts Flow is like this the very first request comes to the Action servlet which the part of the Controller component of the MVC architeture , then the requets is disptachted to the request processor the request processor find the specified mapping url of the response in invoke the page.
The struts config.xml use to define as the mapping from the pages.After finding the respective mapping the bean is populated if its their and the forward to the requested path.
When we deploy our application in the server, at first the container reads the information from web.xml file.Here ActionServlet object will be created and init() of ActionServlet will be called.Here ActionServlet is the backbone to the whole application.
When client send a rewuest using .jsp extension , getters() and reset() of FormBean will be called. When client fill the form and press on submit button, then setters() and validate() will be called. If the data is not valid ,then the form redirects to another page which is specified in struts-config.xml file. If the data is valid , then only Action class object will be created.
In Action class , have execute() which have return type of ActionForward. We can specify the business logic in Model and provide that object in execute(). After completion of business logic execution , then it forwards to another page ( either success or failure) , whichis specified in struts-config.xml file.