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)

PDF
Jsf Framework
PDF
Jsf2 overview
ODP
Development of web apps based on JSF (TU Vienna)
PDF
Spring MVC introduction HVA
PPT
Module 5.ppt.............................
PPTX
Introduction to ejb and struts framework
PDF
Mvc15 (1)
PPTX
ASP.NET MVC as the next step in web development
PPTX
Engineering the Java Web Application (MVC)
PPT
MVC
PPTX
Asp.Net MVC3 - Basics
PDF
Weblogic
ODP
Java Web Programming [1/9] : Introduction to Web Application
PPT
Design patterns
PPTX
Frameworks in java
PDF
Jinal desai .net
DOCX
Month 2 report
PDF
Struts Basics
PDF
Spring mvc 2.0
PPS
Web Component Development with Servlet and JSP Technologies Unit 01
Jsf Framework
Jsf2 overview
Development of web apps based on JSF (TU Vienna)
Spring MVC introduction HVA
Module 5.ppt.............................
Introduction to ejb and struts framework
Mvc15 (1)
ASP.NET MVC as the next step in web development
Engineering the Java Web Application (MVC)
MVC
Asp.Net MVC3 - Basics
Weblogic
Java Web Programming [1/9] : Introduction to Web Application
Design patterns
Frameworks in java
Jinal desai .net
Month 2 report
Struts Basics
Spring mvc 2.0
Web Component Development with Servlet and JSP Technologies Unit 01
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
Encapsulation_ Review paper, used for researhc scholars
PPTX
A Presentation on Artificial Intelligence
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
KodekX | Application Modernization Development
Encapsulation_ Review paper, used for researhc scholars
A Presentation on Artificial Intelligence
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Spectral efficient network and resource selection model in 5G networks
Unlocking AI with Model Context Protocol (MCP)
Mobile App Security Testing_ A Comprehensive Guide.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Review of recent advances in non-invasive hemoglobin estimation
Dropbox Q2 2025 Financial Results & Investor Presentation
NewMind AI Weekly Chronicles - August'25 Week I
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Digital-Transformation-Roadmap-for-Companies.pptx
Understanding_Digital_Forensics_Presentation.pptx
20250228 LYD VKU AI Blended-Learning.pptx
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
The AUB Centre for AI in Media Proposal.docx
KodekX | Application Modernization Development

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 thananum@gmail.com www.facebook.com/imcinstitute www.imcinstitute.com 23