Struts2 Architecture



Struts2 is based upon MVC2 Architecture.
MVC stands for Model View Control. Model will work with business logic of an application and it's nothing but bean and pojo as a model (It is nothing but a database related programming).

View works as a presentation logic in an application. We use jsp/html for presentation logic.

Control works as a business logic in an application which is used to handle request and response and execute a particular logic. We use servlet as a controller.

Execution flow of Struts2



When a client puts request to the application, the request will be received by the container.

The container loads the web.xml file and verify the URL. After verification, the request is transferred to Filter Dispatcher by the container.

Filter Disptcher takes the help of ActionProxy and ConfigurationManager to read the struts.xml file. (Configuration class loads the struts.xml)

FilterDispatcher, ActionProxy, ConfigurationManager, Struts2 work as front Controller. After getting information from struts.xml and ConfigurationManager, ActionProxy invokes the ActionInvocation which executes the interceptors.

ActionInvocation receives the result generated by the action class.
Then ActionProxy transfers the result back to the FilterDispatcher and FilterDispatcher finds the view and sends the result.