Friday, February 19, 2010

MVC Architecture

MVC stands for “model, view, controller.”

Model

The model refers to the data of an application after it has been retrieved from a database. The model is typically made up of objects which reside in RAM memory.

View
The view refers to the presentation of the data on the screen.

Controller
The controller refers to the request and response handler for the application. The controller is usually created with servlets.

How it all fits together

To fully understand how MVC architecture works, let’s think about what happens when an HTTP request is made with a web application. When someone clicks on a link to go to a new webpage, a request is made to the server. The controller then decides what page the user needs to go to, and what data needs to be sent. The application queries the appropriate databases, and puts the resulting data into the model.

At this point, the model can be easily manipulated, sorted, and filtered, and used to create the view that the user will see when the page first loads. The HTML content can be generated with a JSP (if the application uses the Java platform) and sent back to the client machine as a response.

No comments: