What Is MVC web application architecture | FAQ

Must Know

Model View Controller (MVC) architecture, helps in the separation of application logic and presentation of HTML content. The Model is the logic of the site, the rules that determine what is shown, and to whom it is shown. The View component of this architecture is naturally the JSPs that display the content that is created. Finally, the Controller designates which part of the Model is invoked, and which JSP is used to render the data. Another way to put this is that the Controller defines the structure of the site and the page flow logic. This information is read from a configuration file, and not buried inside Web pages.Below figure shows a diagram of the MVC architecture

MVC architecture

There are two typical types of Model 2 architectures: strict and loose. The strict version designates the role of the Controller to a single servlet, which extracts the information needed to route the query to a piece of logic, executes the logic component, and then forwards the result of the execution to a JSP. A popularly used MVC implementation is the Struts framework ( http://struts.apache.org/)

This framework implements a standard servlet for routing execution. Each piece of functionality is implemented as a special type of Struts component known as an Action . Each Action defines a single method and can place a variety of objects where the JSP that is invoked can use them to render the page. In this type of architecture, the sequence of execution is often very reliable. Below figure illustrates this sequence.

MVC architecture

An expanded example of the MVC strict architecture is shown in below Figure. In this diagram, you can see that the single Controller selects the correct logic to execute, and then forwards the result to the View, which renders the results for the client.

MVC Architecture

Small-scale, homegrown sites that are not based on a framework are often a looser version of this architecture. Several servlets each take the role of a Controller and part of the Model. In this version of the Model 2 architecture, the JSPs are still designed so that they contain very little or no logic and the servlets handle all of the functions of the application. This second model is quite popular because it promotes high productivity in the short term, and can be easier to understand than the strict MVC architecture.

In sites that have a pure MVC architecture, the structure of the site is (at least in principle) quite flexible. The site is divided into units of functionality that can be reused in multiple situations, as well as pages that can be reused. For example, a page that displays contact details in a Web site may be used for creating a new contact, updating an old contact, viewing an existing contact, and updating a user’s contact details.

A site that allows content management may use the same JSP and servlet code for uploading a variety of documents, each with different needs (such as a report, a tender request, and a procedures manual). As the site expands, these components will need to be integrated with new functionality. The flow control must be configured before the various components will work together correctly. This does, however, represent a very reusable and updateable site. The site can be reconfigured according to business needs and customer requests with minimal code rewrite.

In case of any ┬ęCopyright or missing credits issue please check CopyRights page for faster resolutions.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.