Loading sub-menu...

Model-View-Controller Pattern

The MVC pattern decouples data access and business logic from data presentation and user interaction by introducing an intermediate component: the controller.

  • Model - The model represents the information (the data) of the application. It can also represent the business rules used to manipulate the data.
  • View - The view corresponds to elements of the user interface, typically JSP pages and Struts Tiles.
  • Controller - The controller manages details involving the communication to the model of user actions. In Struts, the controller is really the combination of a number of Actions and an Action servlet.
  • 1 - The view knows exactly what kind of model it observes and it has a strongly typed pointer to the model, allowing it to call any of the model's methods.
  • 2 - The view may have a weakly-typed (base class) pointer to the controller. It should not call any methods in the controller other than those defined in the base class because you may want to switch out the controller for another.
  • 3 - The model's view pointer is weakly typed (only a base class pointer); the model should know nothing about the views which control it.
  • 4 & 5 - The controller has pointers to both the model and the view and knows the type of both. Since the controller defines the behavior of the triad, it must know the type of both the model and the view in order to translate user input into application response.

The popular open-source Struts Framework provides a Java implementation of the MVC Pattern. The Spring Application Framework is another open-source Java toolkit which implements the pattern and is growing in popularity.

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.