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

PDF
Java Web Programming [4/9] : JSP Basic
PDF
Java Web Programming [3/9] : Servlet Advanced
PDF
Java Web Programming [7/9] : Struts2 Basics
PDF
Java Web Programming [2/9] : Servlet Basic
PDF
Java Web Programming [5/9] : EL, JSTL and Custom Tags
PDF
Lap trinh web [Slide jsp]
PDF
J2EE jsp_01
DOCX
TY.BSc.IT Java QB U4
Java Web Programming [4/9] : JSP Basic
Java Web Programming [3/9] : Servlet Advanced
Java Web Programming [7/9] : Struts2 Basics
Java Web Programming [2/9] : Servlet Basic
Java Web Programming [5/9] : EL, JSTL and Custom Tags
Lap trinh web [Slide jsp]
J2EE jsp_01
TY.BSc.IT Java QB U4

What's hot (20)

PDF
JSP Technology I
PDF
Lecture 9 - Java Persistence, JPA 2
PPT
Java EE Introduction
PPT
Java Server Faces (JSF) - Basics
PDF
Lecture 5 JSTL, custom tags, maven
DOCX
TY.BSc.IT Java QB U5&6
PPT
Jsp ppt
PDF
Lecture 1: Introduction to JEE
PPTX
Jsf presentation
DOC
24 collections framework interview questions
PPT
Struts,Jsp,Servlet
DOCX
TY.BSc.IT Java QB U5
PPSX
JSP - Part 2 (Final)
PDF
Lecture 3: Servlets - Session Management
PPSX
Spring - Part 4 - Spring MVC
PPTX
Javatwo2012 java frameworkcomparison
PDF
Java EE 7 - Overview and Status
PDF
Spring design-juergen-qcon
PDF
Contextual Dependency Injection for Apachecon 2010
JSP Technology I
Lecture 9 - Java Persistence, JPA 2
Java EE Introduction
Java Server Faces (JSF) - Basics
Lecture 5 JSTL, custom tags, maven
TY.BSc.IT Java QB U5&6
Jsp ppt
Lecture 1: Introduction to JEE
Jsf presentation
24 collections framework interview questions
Struts,Jsp,Servlet
TY.BSc.IT Java QB U5
JSP - Part 2 (Final)
Lecture 3: Servlets - Session Management
Spring - Part 4 - Spring MVC
Javatwo2012 java frameworkcomparison
Java EE 7 - Overview and Status
Spring design-juergen-qcon
Contextual Dependency Injection for Apachecon 2010
Ad

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

ODP
Development of web apps based on JSF (TU Vienna)
PPTX
Engineering the Java Web Application (MVC)
PDF
Java Edge.2008.Web.Frameworks.Catagorized
PDF
Jsf Framework
PDF
Struts notes
PDF
Struts natraj - satya
PDF
Struts natraj - satya
PDF
Jsf2 overview
PDF
Introduction To J Boss Seam
PDF
Spring vs. asp.net mvc
KEY
Multi Client Development with Spring
PDF
Jsf2 overview
PPTX
WebBee rapid web app development teck stack
PDF
Sun Java EE 6 Overview
PDF
Java EE 6 & GlassFish v3: Paving the path for the future - Tech Days 2010 India
PPTX
L17 Presentation Layer Design
PDF
Spring MVC introduction HVA
PPT
Ppt for Online music store
PDF
Spark IT 2011 - Java EE 6 Workshop
PDF
Jspx Jdc2010
Development of web apps based on JSF (TU Vienna)
Engineering the Java Web Application (MVC)
Java Edge.2008.Web.Frameworks.Catagorized
Jsf Framework
Struts notes
Struts natraj - satya
Struts natraj - satya
Jsf2 overview
Introduction To J Boss Seam
Spring vs. asp.net mvc
Multi Client Development with Spring
Jsf2 overview
WebBee rapid web app development teck stack
Sun Java EE 6 Overview
Java EE 6 & GlassFish v3: Paving the path for the future - Tech Days 2010 India
L17 Presentation Layer Design
Spring MVC introduction HVA
Ppt for Online music store
Spark IT 2011 - Java EE 6 Workshop
Jspx Jdc2010
Ad

More from IMC Institute (20)

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

Recently uploaded (20)

PDF
Event Presentation Google Cloud Next Extended 2025
PDF
Advanced Soft Computing BINUS July 2025.pdf
PDF
How Onsite IT Support Drives Business Efficiency, Security, and Growth.pdf
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
AI And Its Effect On The Evolving IT Sector In Australia - Elevate
PDF
cuic standard and advanced reporting.pdf
PDF
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
PDF
CIFDAQ's Market Wrap: Ethereum Leads, Bitcoin Lags, Institutions Shift
PDF
madgavkar20181017ppt McKinsey Presentation.pdf
PDF
Advanced IT Governance
PDF
DevOps & Developer Experience Summer BBQ
PPTX
Cloud computing and distributed systems.
PDF
HCSP-Presales-Campus Network Planning and Design V1.0 Training Material-Witho...
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Newfamily of error-correcting codes based on genetic algorithms
PDF
Sensors and Actuators in IoT Systems using pdf
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Event Presentation Google Cloud Next Extended 2025
Advanced Soft Computing BINUS July 2025.pdf
How Onsite IT Support Drives Business Efficiency, Security, and Growth.pdf
MYSQL Presentation for SQL database connectivity
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
AI And Its Effect On The Evolving IT Sector In Australia - Elevate
cuic standard and advanced reporting.pdf
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
CIFDAQ's Market Wrap: Ethereum Leads, Bitcoin Lags, Institutions Shift
madgavkar20181017ppt McKinsey Presentation.pdf
Advanced IT Governance
DevOps & Developer Experience Summer BBQ
Cloud computing and distributed systems.
HCSP-Presales-Campus Network Planning and Design V1.0 Training Material-Witho...
20250228 LYD VKU AI Blended-Learning.pptx
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Newfamily of error-correcting codes based on genetic algorithms
Sensors and Actuators in IoT Systems using pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows

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