Flow of Model View Controller architecture

12/2/10
Posted by Fulto



MVC Architecture   provides the easiness for developing web applications by separating business logic and display logic.
MVC architecture have main three components that are
1) Model 
2) View
3) Controller

Model:    Model component specifies the business logic and data of web applications.
                              Business logic includes storing, updating of data into relational databases.
View:
                  View Component represents the display logic of output which will sent to the client.
                               In this view developer never worried about the business logic.

Controller:  Controller Component specifies the flow of requests of applications.

The following figure shows the communications between model, view and controller components.


The following are the steps in the above figure:

  1. A browser request is submitted to and handled by the Action Servlet class, which has one physical instance per server.
  2. The Action Servlet calls the Request Processor to prepare the request and response objects, determine action mapping etc.
  3. The Request Processor creates (or re-uses) the corresponding Action Form bean, populates it with the input fields from the html form and invokes form validation (if required).
  4. Using the action mapping in its config file, the Request Processor passes control to the appropriate Action Class. The Struts framework pools instances of Action classes; therefore, if the action has already been requested, it will be retrieved from the instance pool, as opposed to being created with every request. However, without multi-threading, this can lead to significant collisions when multiple users are accessing the same action.
  5. The Action Class invokes business logic beans and passes the Action Form (or a portion of it) to the model. The model may be EJB-based, or consist of plain Java objects.
  6. After the action completes execution, it is returned as an Action Forward object which determines the target of the request.
  7. Control is finally returned to the Request Processor, which forwards the request to the appropriate target.
  8. The JSP page may get data from the Model through a set of tag libraries.




People who read this post also read :



0 comments: