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
- Model 1 Architecture
- Model 2 (MVC) Architecture
** UPDATE: Struts 2 Complete tutorial now available here.
Model 1 Architecture
Flow of the Model 1 architecture.
- Browser sends request for the JSP page
- JSP accesses Business service Bean class and invokes business logic
- Business service Bean class connects to the database to store/retrieve data
- 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.