Pages Navigation Menu

Coding is much easier than you think

Model 1 and Model 2 (MVC) Architecture



Student: Master,  what is the difference between MVC 1 and MVC 2 ?
Master: Grasshopper, there is no such thing as MVC 1 and MVC 2, there’s just MVC. if you meant to ask about the difference between Model 1 and Model 2 with respect to web applications, then this article will help you out.
In Java there are two types of programming models

  1. Model 1 Architecture
  2. Model 2 (MVC) Architecture

** UPDATE: Struts 2 Complete tutorial now available here.

Model 1 Architecture


Flow of the Model 1 architecture.

  1. Browser sends request for the JSP page
  2. JSP accesses Business service Bean class and invokes business logic
  3. Business service Bean class connects to the database to store/retrieve data
  4. Response generated by JSP is sent to the browser

Navigation control is decentralized

Model 2 (MVC) Architecture


Model 2 is based on the MVC (Model View Controller) design pattern.

  • Model         – Represents the data and business logic of the application.
  • View          – Represents the presentation.
  • Controller   – The controller module acts as an interface between view and model.

It intercepts all the requests i.e. receives input and commands to Model / View to change  accordingly.
Advantage of Model 2 (MVC) Architecture

  • Navigation control is centralized (Controller only has the control to determine the next page)
  • Easy to maintain, extend and test.

Disadvantage of Model 2 (MVC) Architecture
If we change the controller code, we need to recompile the class and redeploy the application.

About Mohaideen Jamil

I'm a Full stack developer of IT exp in J2EE, AngularJs, MicroServices, Docker, Spring (Boot, MVC, Cloud), Bluemix, DevOps. Follow me on Facebook or Google Plus. If you like my tutorials, consider making a donation to this charity, thanks.

%d bloggers like this: