×
☰ See All Chapters

MVC Architecture

mvc-architecture-0
 
  • To overcome the problem of Model 1 architecture, MVC architecture can be used. In this MVC architecture for each functionality we need to write separate multiple or shared servlet/ jsp and one or more model components.  

  • In MVC there is clear separation among all the logics and there are 3 main components. 

    1. Model (M): It contains the business logic and the persistence logic. 

    2. View (V): It contains the presentation logic. 

    3. Controller(C): It contains the controller logic/Integration logic, controls Model and View. 

  • The logic that is used to prepare user interface and to display results by applying styles is called presentation logic. 

  • The main logic of the application that generates results based on given input values is called business logic. 

  • The permanent storage unit that can store data is called persistent store. CRUD operations on the Database table - persistent store are called persistent operations. The logic used for this purpose is called persistent logic. 

Read X1,X2,X3 values from request

Presentation Logic

Sum = X1+X2+X3

Business logic

Store Sum in Database

Persistence logic

Display Sum

Presentation Logic

 

  • Logic that controls and monitors all the operations of MVC architecture based applications is called Integration logic. This logic contains code to perform the communications between view layer resources and model layer resources. 

  • The Java class that contains purely persistence logic and separates that logic from other logics of the applications is called DAO (Data Access Object) class. Any modifications done in persistent logic of DAO will not affect other logics of the applications. 

  • Below table gives the sample combinations of technologies used in applications in different layers. 

View

Controller

Model

Business logic

Persistence logic

JSP

Servlet

JavaBean

DAO class

JSP

Servlet

EJB Session Bean Component

EJB entity bean

JSP/XHTML

JSF

javax.faces.webapp.FacesServlet

 

JSF bean classes

Any persistence technology like JPA, Hibernate, JDBC

JSP/HTML

Spring MVC

org.springframework.web.servlet.DispatcherServlet

 

Spring Controller class

Any persistence technology like JPA, Hibernate, JDBC

 

 


All Chapters
Author