Pages Navigation Menu

Coding is much easier than you think

Model 1 and Model 2 (MVC) Architecture

 

Misconceptions

 
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

 
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

 
Disadvantage
Navigation control is decentralized
 

Model 2 (MVC) Architecture

 
model-2-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


Am currently working as a Struts 2 Developer in a reputed IT Organisations. I can help you with teaching Core java and Struts 2. Follow me on Facebook or Google Plus. If you like my tutorials, consider making a donation to this charity, thanks.

  • prakash

    very nice tutorial, I am planing to do coaching but after following you page now i can say i don’t need any coaching..
    can you please tell me how the controller intercepts all the requests i.e. receives input and how it commands to Model / View to change accordingly. and also show me a flow diagram please.

  • subinoy dey

    can you please tell me how the controller intercepts all the requests i.e. receives input and how it commands to Model / View to change accordingly. and also show me a flow diagram please.
    Subinoy Dey
    mail id: hisubi@rediffmail.com
    other wise your tutorial is very nice.