Model-2 Architecture (MVC)
  • MVC(Model , View , Controller)
    • Model
      • Model= business logic+ persistence logic.
      • S/w: Java bean, EJB, spring with hibernates and etc.
      • Eg: accounts officer
    • View
      • View=presentation logic
      • S/w: jsp, html
      • Eg: Beautician
    • Controller
      • Controller=Integration logic
      • S/w: Servlet, Servlet filter
      • Eg: traffic police
  • Integration logic of controller servlet :
    • it is responsible to gather request from browser window
    • to pass the request to appropriate model layer program
    • to collect the result from model layer program
    • to pass the result to view layer program
    • this logic monitor and controls all the operation of web application execution
  • MVC Architecture
    • MVC architecture  based web application development is nothing but developing web application by having multiple layer and taking the support of multiple technologies to develop these logic
    • Java connector architecture(JCA): it is a interaction between java and ERP & CRP applications
    • MVC architecture
    • The controller of MVC architecture based web application stands in the center of the web application and controls all the executions related to each request processing


    • With respect to the diagram
      • End user gives initial request to web application from browser window
      • The controller Servlet traps and takes the request and gather the request data
      • The integration logic of controller Servlet sends the request to appropriate business component of model layer
      • The business logic of model component execute and used persistence logic to interact with EIS s/w if necessary
      • The business logic execution result comes to controller Servlet
      • Controller Servlet uses integration logic and passes unformatted result to view layer component called jsp
      • The presentation logic of jsp execution to format the result and this formatted result gores to browser as response
  • Advantage of MVC
    • Since multiple layers are their in web application their will be clean separation of logics and roles
    • Modification done in one logic will not effect other logic
    • Easy to maintain and enhancement the web application
FAQ
How parallel development is possible
The project leader divides the team into two parts
Part 1: web authors
These programmers take care of presentation logic by using jsp, html
Part 2: J2ee developers:
These programmer develop business logic and persistence logic by using j2ee , 3rd party technologies

Note
Since these two parties can work parallel and controller servlet can also be developed parallel. So we can say that parallel development is possible


    • Parallel development is possible so product is high
    • EJB, spring, hibernate technologies give built in middle ware service. so programmer will not be over burdened
    • Mvc architecture is industries default stand to develop medium, large scale web application
  • Disadvantage of MVC
    • Knowledge on multiple technologies is require
    • For parallel development more programmers are required
  • MVC Principle
    • In Mvc architecture every layer is given for certain logics development So place only those logics and don’t place extra logics
    • All the operation that are taking place in web application execution must be kept tracked by the Servlet
    • Their can be multiple jsp or other program in view layer , their can be multiple business components in model layers but their must be only one Servlet acting as controller in controller layer
    • Two jsp/two view layers program must not interact with each other directly this communication should happen throw controller Servlet
    • View layer components must not interact with model layer components directly and vice versa this communication should take place through controller Servlet
    • No web resource of web application should take request from browser directly y all the request coming to web application must be trapped and must be taken by the controller Servlet
Design Pattern:
    • these are the set of rules which comes as best solution for reoccurring problems of application development
    • these are best practice of working with to develop effective s/w application effectively
    • if these rules becomes industry standards to work with s/w technologies and to create s/w then it is called Architecture
    • when these Mvc rules have become industry standards to develop the web application and to create new s/w like struts jsp it is called MVC architecture

FAQ

Can we change the roles of various technologies that are used in MVC architecture based web application development?

A) Yes, it is possible but not recommended to do
Scenario 1 (servlet as view component)
1.      the presentation logic of web site will change at regular intervals
2.      when modification is done in the source code of servlet we need to recompile the servlet and we need to reload the web application
3.      Modification done in jsp source code will be effected without recompilation of jsp and reloading effected without recompilation of jsp and reloading of web application. so it is recommended to take jsp as view layer components by placing presentation logic
Scenario 2 (jsp as controller)
1.      if always recommended to develop jsp as java code less jsp to increase readability of jsp
2.      when jsp is taken as controller we need to place statements to interact with model layer component like ejb components and spring application
3.      But this is not a industry standard to work with jsp.
4.      jsp technology doesn’t provide any predefines tags to communicate with ejb components, spring app and etc model components
5.      due to this we recommended to take servlet as controller
 Scenario 3 (ejb component/spring application/ hibernate application as view layer/controller layer component)
1.      only web resource programs like servlet, jsp programs which can work with http protocol request response, operation can be used as controller and view layer components
2.      since ejb component, spring app and hibernate app are not web components and since they can’t directly deal with http request and response operation is not possible to take them as controller layer and view layer components
Scenario 4 (another servlet/jsp as model component /application)
1.antoher servlet/ jsp means a separate servlet jsp will be taken in model layer to place business logic and related logic irrespective of jsp’ and servlet available in view controllers layers