Model, View, Controller (MVC)

There are three major components in a Web Applications Development: Model, View, Controller (MVC)

  JSP JavaServer Pages Website 
  • In JSP, they are the Bean, the JSPs and the Controller.
    1. Model
      In a JSP web application, the Bean is the model. The model defines the data that will be used in the application. It also defines the operations that can be performed on the data. Beans are designed to only contain data and help with validation to the web application. One type of validation is default validation. In default validation, the user/’s data must meet criteria. If the data does not meet the criteria, then a default value is used in place of the data that the user entered. The model is where the data processing will be done. The most important aspect of a web application is data processing. The model encapsulates the data and all the methods that work on it.

    2. View
      The view displays the data to the user. The view does not do any of the processing of the data, it only presents and accepts data. There are usually multiple views in an application. In a JSP web application, each JSP is a separate view. The views are simple. They contain HTML and a few directives to display the data from the model. It is best not to add code to the view.

    3. Controller
      The Controller is the program that ties the views and the models together. In a JSP web application, the Controller Servlet is the Controller. The Controller is important because it is the program that is handling the request from the browser and sending a response back to the server. The Controller will delegate responsibility to the model whenever it can.


  PHP Website  
  • In PHP the implementation of the Model, View, Controller (MVC) is similar as in JSP.
    1. The Model
      We call it the Back End. Here we control all the data related functions of the Web Applications.
      In the Back End we use many languages such as:
      MySql, Postgres, C, Perl, Java, and of course PHP. These languages allows to do any type of data validation we need.

    2. The View
      We call it the Front End which is the manner that the user comunicates with the Web application. It contains Html and many other languages such as CSS and JavaScript.

    3. The Controller
      The purpose of the Controller is to direct the trafic of all functions between the Front End and the Back End. I recomend that all the code in the controller be encapsulated into PHP so that regarless of the language used, the code can not be seen by the users. We can use multiple languages inside the controller such as HTML, PHP, Java, Perl, C, JavaScript and others.