SlideShare a Scribd company logo
Module 6: MVC


Thanisa Kruawaisayawan
 Thanachart Numnonda
 www.imcinstitute.com
Objectives
 Introduction of MVC pattern
 Evolution of Web Application design
  architecture
     Model 1
     Model 2
     Application frameworks




                                        2
MVC Pattern




              3
Three Logical Layers in a Web
         Application: Model
   Model (Business process layer)
     Models    the data and behavior behind the business
      process
     Responsible    for actually doing
           Performing DB queries
           Calculating the business process
           Processing orders
     Encapsulate  of data and behavior which are independent
      of presentation                                         4
Three Logical Layers in a Web
            Application: View
   View (Presentation layer)
     Display   information according to client types
     Display   result of business logic (Model)
     Not concerned with how the information was
      obtained, or from where (since that is the
      responsibility of Model)


                                                        5
Three Logical Layers in a Web
         Application: Controller
   Controller (Control layer)
     Serves  as the logical connection between the user's
      interaction and the business services on the back
     Responsible  for making decisions among multiple
      presentations
           e.g. User's language, locale or access level dictates a different
            presentation.
     A request  enters the application through the control layer,
      it will decide how the request should be handled and
      what information should be returned
                                                                                6
Web Applications
 It is often advantageous to treat each layer
  as an independent portion of your
  application
 Do not confuse logical separation of
  responsibilities with actual separation of
  components
 Some or of the layers can be combined
  into single components to reduce
  application complexity
                                                 7
Evolution of MVC Architecture
1.No MVC
2.MVC Model 1 (Page-centric)
3.MVC Model 2 (Servlet-centric)
4.Web application frameworks
  
      Struts
1.Standard-based Web application framework
  
      JavaServer Faces (JSR-127)
                                             8
Evolution of Web Application
Design until Model 1 Architecture




     No MVC   Model 1 architecture
                                     9
Model 1 Architecture (Page-centric)
               1
            Request     JSP
               4       pages
  BROWSER




            Response

                            2


                         Java      3
                         Bean


                        Servlet          Enterprise
                       Container        Information
                                       Systems (EIS)   10
Page-centric Architecture
   Composed of a series of interrelated JSP pages
    – JSP pages handle all aspects of the application -
      presentation, control, and business process
   Business process logic and control decisions are
    hard coded inside JSP pages
       in the form of JavaBeans, scriptlets, expression
   Next page selection is determined by
    – A user clicking on a hyper link, e.g. <A HERF="find.jsp>
    – Through the action of submitting a form, e.g. <FORM
      ACTION="search.jsp">                                       11
Page-centric Architecture


memu.jsp      catalog.jsp       checkout.jsp




                            dataBase

     page–centric catalog application          12
Page-centric Scenario
                                   View
                                search.html
           Request 1

                response        list.jsp
Client
                                                         Model
                     response
                                   forward

                                                           JavaBeans
             Request 2
                                Controller

         Request 3
                                find.jsp
                                              redirect

                                delete.jsp



                                                                       13
Model 2 Architecture (Servlet-
          centric)                                          MVC Design Pattern

             1
          Request
                        (Controller
                             )
BROWSER




                          Servlet

                     Redirect   3


                                    In
                                                 2


                                      st
                                         an
                                           tia
                                           te
             5                                        (Model)
                          (View)                     Java Bean
          Response         JSP             4



                           Servlet Container                            (EIS)
                                                                                 14
Why Model 2 Architecture?
   What if you want to present different JSP
    pages depending on the data you receive?
     JSP technology alone even with JavaBeans and
      custom tags (Model 1) cannot handle it well
   Solution
     Use Servlet and JSP together (Model 2)
     Servlet handles initial request, partially process
     the data, set up beans, then forward the results to
     one of a number of different JSP pages
                                                           15
Servlet-centric Architecture
   JSP pages are used only for presentation
      Control  and application logic handled by a servlet
       (or set of servlets)
   Servlet serves as a gatekeeper
     – Provides common services, such as authentication,
       authorization, login, error handling, and etc

   Servlet serves as a central controller
     – Act as a state machine or an event dispatcher to decide upon the
       appropriate logic to handle the request
     – Performs redirecting
                                                                          16
Servlet-centric Scenario
                                   View
                                search.html
           Request 1

                response        list.jsp
Client
                                              Model
                     response
                                   forward

                                                JavaBeans
             Request 2
                                Controller

         Request 3
                                  servlet




                                                            17
Web Application Frameworks
 Based on MVC Model 2 architecture
 Web-tier applications share common set of
  functionality
     Dispatching HTTP requests
     Invoking model methods
     Selecting and assembling views
   Provide classes and interfaces that can be
    used/extended by developers
                                                 18
Why Web Application Framework?
   De-coupling of presentation tier and business logic into separate
    components
   Provides a central point of control
   Provides rich set of features
   Facilitates unit-testing and maintenance
   Availability of compatible tools
   Provides stability
   Enjoys community-supports
   Simplifies internationalization
   Simplifies input validation                                     19
Why Web Application Framework?
   Frameworks have evolved with Java Server
    technology
   JSP/Servlets are still hard to use
   Frameworks define re-usable components to
    make this job easier.
   A good framework defines how components
    work to create a usable application.



                                                20
Web Application Frameworks

 Apache Struts
 JavaServer Faces (JSR-127)
     A server side user interface component
     framework for JavaTM technology-based web
     applications
 Echo
 Tapestry

                                                 21
Acknowledgement
 Most contents are borrowed from the
presentation slides of Sang Shin, Java™
Technology Evangelist, Sun Microsystems,
Inc.




                                           22
Thank you

   thananum@gmail.com
www.facebook.com/imcinstitute
   www.imcinstitute.com



                                23

More Related Content

What's hot (20)

PDF
JSP Technology I
People Strategists
 
PDF
Lecture 9 - Java Persistence, JPA 2
Fahad Golra
 
PPT
Java EE Introduction
ejlp12
 
PPT
Java Server Faces (JSF) - Basics
BG Java EE Course
 
PDF
Lecture 5 JSTL, custom tags, maven
Fahad Golra
 
DOCX
TY.BSc.IT Java QB U5&6
Lokesh Singrol
 
PPT
Jsp ppt
Vikas Jagtap
 
PDF
Lecture 1: Introduction to JEE
Fahad Golra
 
PPTX
Jsf presentation
Ashish Gupta
 
DOC
24 collections framework interview questions
Arun Vasanth
 
PPT
Struts,Jsp,Servlet
dasguptahirak
 
DOCX
TY.BSc.IT Java QB U5
Lokesh Singrol
 
PPSX
JSP - Part 2 (Final)
Hitesh-Java
 
PDF
Lecture 3: Servlets - Session Management
Fahad Golra
 
PPSX
Spring - Part 4 - Spring MVC
Hitesh-Java
 
PPTX
Javatwo2012 java frameworkcomparison
Jini Lee
 
PDF
Java EE 7 - Overview and Status
Java Usergroup Berlin-Brandenburg
 
PDF
Spring design-juergen-qcon
Yiwei Ma
 
PDF
Contextual Dependency Injection for Apachecon 2010
Rohit Kelapure
 
JSP Technology I
People Strategists
 
Lecture 9 - Java Persistence, JPA 2
Fahad Golra
 
Java EE Introduction
ejlp12
 
Java Server Faces (JSF) - Basics
BG Java EE Course
 
Lecture 5 JSTL, custom tags, maven
Fahad Golra
 
TY.BSc.IT Java QB U5&6
Lokesh Singrol
 
Jsp ppt
Vikas Jagtap
 
Lecture 1: Introduction to JEE
Fahad Golra
 
Jsf presentation
Ashish Gupta
 
24 collections framework interview questions
Arun Vasanth
 
Struts,Jsp,Servlet
dasguptahirak
 
TY.BSc.IT Java QB U5
Lokesh Singrol
 
JSP - Part 2 (Final)
Hitesh-Java
 
Lecture 3: Servlets - Session Management
Fahad Golra
 
Spring - Part 4 - Spring MVC
Hitesh-Java
 
Javatwo2012 java frameworkcomparison
Jini Lee
 
Java EE 7 - Overview and Status
Java Usergroup Berlin-Brandenburg
 
Spring design-juergen-qcon
Yiwei Ma
 
Contextual Dependency Injection for Apachecon 2010
Rohit Kelapure
 

Similar to Java Web Programming [6/9] : MVC (20)

ODP
Development of web apps based on JSF (TU Vienna)
blahap
 
PPTX
Engineering the Java Web Application (MVC)
abhishekoza1981
 
PDF
Java Edge.2008.Web.Frameworks.Catagorized
roialdaag
 
PDF
Jsf Framework
Marimuthu Udayakumar
 
PDF
Struts notes
dssreenath
 
PDF
Struts natraj - satya
Satya Johnny
 
PDF
Struts natraj - satya
Seshadri Pullaanagari
 
PDF
Jsf2 overview
sohan1234
 
PDF
Introduction To J Boss Seam
ashishkulkarni
 
PDF
Spring vs. asp.net mvc
Umar Ali
 
KEY
Multi Client Development with Spring
Joshua Long
 
PDF
Jsf2 overview
musaibasrar
 
PPTX
WebBee rapid web app development teck stack
ALDAN3
 
PDF
Sun Java EE 6 Overview
sbobde
 
PDF
Java EE 6 & GlassFish v3: Paving the path for the future - Tech Days 2010 India
Arun Gupta
 
PPTX
L17 Presentation Layer Design
Ólafur Andri Ragnarsson
 
PDF
Spring MVC introduction HVA
Peter Maas
 
PPT
Ppt for Online music store
ADEEBANADEEM
 
PDF
Spark IT 2011 - Java EE 6 Workshop
Arun Gupta
 
PDF
Jspx Jdc2010
suppport jspx
 
Development of web apps based on JSF (TU Vienna)
blahap
 
Engineering the Java Web Application (MVC)
abhishekoza1981
 
Java Edge.2008.Web.Frameworks.Catagorized
roialdaag
 
Jsf Framework
Marimuthu Udayakumar
 
Struts notes
dssreenath
 
Struts natraj - satya
Satya Johnny
 
Struts natraj - satya
Seshadri Pullaanagari
 
Jsf2 overview
sohan1234
 
Introduction To J Boss Seam
ashishkulkarni
 
Spring vs. asp.net mvc
Umar Ali
 
Multi Client Development with Spring
Joshua Long
 
Jsf2 overview
musaibasrar
 
WebBee rapid web app development teck stack
ALDAN3
 
Sun Java EE 6 Overview
sbobde
 
Java EE 6 & GlassFish v3: Paving the path for the future - Tech Days 2010 India
Arun Gupta
 
L17 Presentation Layer Design
Ólafur Andri Ragnarsson
 
Spring MVC introduction HVA
Peter Maas
 
Ppt for Online music store
ADEEBANADEEM
 
Spark IT 2011 - Java EE 6 Workshop
Arun Gupta
 
Jspx Jdc2010
suppport jspx
 
Ad

More from IMC Institute (20)

PDF
นิตยสาร Digital Trends ฉบับที่ 14
IMC Institute
 
PDF
Digital trends Vol 4 No. 13 Sep-Dec 2019
IMC Institute
 
PDF
บทความ The evolution of AI
IMC Institute
 
PDF
IT Trends eMagazine Vol 4. No.12
IMC Institute
 
PDF
เพราะเหตุใด Digitization ไม่ตอบโจทย์ Digital Transformation
IMC Institute
 
PDF
IT Trends 2019: Putting Digital Transformation to Work
IMC Institute
 
PDF
มูลค่าตลาดดิจิทัลไทย 3 อุตสาหกรรม
IMC Institute
 
PDF
IT Trends eMagazine Vol 4. No.11
IMC Institute
 
PDF
แนวทางการทำ Digital transformation
IMC Institute
 
PDF
บทความ The New Silicon Valley
IMC Institute
 
PDF
นิตยสาร IT Trends ของ IMC Institute ฉบับที่ 10
IMC Institute
 
PDF
แนวทางการทำ Digital transformation
IMC Institute
 
PDF
The Power of Big Data for a new economy (Sample)
IMC Institute
 
PDF
บทความ Robotics แนวโน้มใหม่สู่บริการเฉพาะทาง
IMC Institute
 
PDF
IT Trends eMagazine Vol 3. No.9
IMC Institute
 
PDF
Thailand software & software market survey 2016
IMC Institute
 
PPTX
Developing Business Blockchain Applications on Hyperledger
IMC Institute
 
PDF
Digital transformation @thanachart.org
IMC Institute
 
PDF
บทความ Big Data จากบล็อก thanachart.org
IMC Institute
 
PDF
กลยุทธ์ 5 ด้านกับการทำ Digital Transformation
IMC Institute
 
นิตยสาร Digital Trends ฉบับที่ 14
IMC Institute
 
Digital trends Vol 4 No. 13 Sep-Dec 2019
IMC Institute
 
บทความ The evolution of AI
IMC Institute
 
IT Trends eMagazine Vol 4. No.12
IMC Institute
 
เพราะเหตุใด Digitization ไม่ตอบโจทย์ Digital Transformation
IMC Institute
 
IT Trends 2019: Putting Digital Transformation to Work
IMC Institute
 
มูลค่าตลาดดิจิทัลไทย 3 อุตสาหกรรม
IMC Institute
 
IT Trends eMagazine Vol 4. No.11
IMC Institute
 
แนวทางการทำ Digital transformation
IMC Institute
 
บทความ The New Silicon Valley
IMC Institute
 
นิตยสาร IT Trends ของ IMC Institute ฉบับที่ 10
IMC Institute
 
แนวทางการทำ Digital transformation
IMC Institute
 
The Power of Big Data for a new economy (Sample)
IMC Institute
 
บทความ Robotics แนวโน้มใหม่สู่บริการเฉพาะทาง
IMC Institute
 
IT Trends eMagazine Vol 3. No.9
IMC Institute
 
Thailand software & software market survey 2016
IMC Institute
 
Developing Business Blockchain Applications on Hyperledger
IMC Institute
 
Digital transformation @thanachart.org
IMC Institute
 
บทความ Big Data จากบล็อก thanachart.org
IMC Institute
 
กลยุทธ์ 5 ด้านกับการทำ Digital Transformation
IMC Institute
 
Ad

Recently uploaded (20)

PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PPTX
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
PPTX
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
PDF
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PDF
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
PDF
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 

Java Web Programming [6/9] : MVC

  • 1. Module 6: MVC Thanisa Kruawaisayawan Thanachart Numnonda www.imcinstitute.com
  • 2. Objectives  Introduction of MVC pattern  Evolution of Web Application design architecture  Model 1  Model 2  Application frameworks 2
  • 4. Three Logical Layers in a Web Application: Model  Model (Business process layer)  Models the data and behavior behind the business process  Responsible for actually doing  Performing DB queries  Calculating the business process  Processing orders  Encapsulate of data and behavior which are independent of presentation 4
  • 5. Three Logical Layers in a Web Application: View  View (Presentation layer)  Display information according to client types  Display result of business logic (Model)  Not concerned with how the information was obtained, or from where (since that is the responsibility of Model) 5
  • 6. Three Logical Layers in a Web Application: Controller  Controller (Control layer)  Serves as the logical connection between the user's interaction and the business services on the back  Responsible for making decisions among multiple presentations  e.g. User's language, locale or access level dictates a different presentation.  A request enters the application through the control layer, it will decide how the request should be handled and what information should be returned 6
  • 7. Web Applications  It is often advantageous to treat each layer as an independent portion of your application  Do not confuse logical separation of responsibilities with actual separation of components  Some or of the layers can be combined into single components to reduce application complexity 7
  • 8. Evolution of MVC Architecture 1.No MVC 2.MVC Model 1 (Page-centric) 3.MVC Model 2 (Servlet-centric) 4.Web application frameworks  Struts 1.Standard-based Web application framework  JavaServer Faces (JSR-127) 8
  • 9. Evolution of Web Application Design until Model 1 Architecture No MVC Model 1 architecture 9
  • 10. Model 1 Architecture (Page-centric) 1 Request JSP 4 pages BROWSER Response 2 Java 3 Bean Servlet Enterprise Container Information Systems (EIS) 10
  • 11. Page-centric Architecture  Composed of a series of interrelated JSP pages – JSP pages handle all aspects of the application - presentation, control, and business process  Business process logic and control decisions are hard coded inside JSP pages  in the form of JavaBeans, scriptlets, expression  Next page selection is determined by – A user clicking on a hyper link, e.g. <A HERF="find.jsp> – Through the action of submitting a form, e.g. <FORM ACTION="search.jsp"> 11
  • 12. Page-centric Architecture memu.jsp catalog.jsp checkout.jsp dataBase page–centric catalog application 12
  • 13. Page-centric Scenario View search.html Request 1 response list.jsp Client Model response forward JavaBeans Request 2 Controller Request 3 find.jsp redirect delete.jsp 13
  • 14. Model 2 Architecture (Servlet- centric) MVC Design Pattern 1 Request (Controller ) BROWSER Servlet Redirect 3 In 2 st an tia te 5 (Model) (View) Java Bean Response JSP 4 Servlet Container (EIS) 14
  • 15. Why Model 2 Architecture?  What if you want to present different JSP pages depending on the data you receive?  JSP technology alone even with JavaBeans and custom tags (Model 1) cannot handle it well  Solution  Use Servlet and JSP together (Model 2)  Servlet handles initial request, partially process the data, set up beans, then forward the results to one of a number of different JSP pages 15
  • 16. Servlet-centric Architecture  JSP pages are used only for presentation  Control and application logic handled by a servlet (or set of servlets)  Servlet serves as a gatekeeper – Provides common services, such as authentication, authorization, login, error handling, and etc  Servlet serves as a central controller – Act as a state machine or an event dispatcher to decide upon the appropriate logic to handle the request – Performs redirecting 16
  • 17. Servlet-centric Scenario View search.html Request 1 response list.jsp Client Model response forward JavaBeans Request 2 Controller Request 3 servlet 17
  • 18. Web Application Frameworks  Based on MVC Model 2 architecture  Web-tier applications share common set of functionality  Dispatching HTTP requests  Invoking model methods  Selecting and assembling views  Provide classes and interfaces that can be used/extended by developers 18
  • 19. Why Web Application Framework?  De-coupling of presentation tier and business logic into separate components  Provides a central point of control  Provides rich set of features  Facilitates unit-testing and maintenance  Availability of compatible tools  Provides stability  Enjoys community-supports  Simplifies internationalization  Simplifies input validation 19
  • 20. Why Web Application Framework?  Frameworks have evolved with Java Server technology  JSP/Servlets are still hard to use  Frameworks define re-usable components to make this job easier.  A good framework defines how components work to create a usable application. 20
  • 21. Web Application Frameworks  Apache Struts  JavaServer Faces (JSR-127)  A server side user interface component framework for JavaTM technology-based web applications  Echo  Tapestry 21
  • 22. Acknowledgement Most contents are borrowed from the presentation slides of Sang Shin, Java™ Technology Evangelist, Sun Microsystems, Inc. 22
  • 23. Thank you [email protected] www.facebook.com/imcinstitute www.imcinstitute.com 23