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

Lecture 9 - Java Persistence, JPA 2
Lecture 9 - Java Persistence, JPA 2Lecture 9 - Java Persistence, JPA 2
Lecture 9 - Java Persistence, JPA 2
Fahad Golra
 
Java EE Introduction
Java EE IntroductionJava EE Introduction
Java EE Introduction
ejlp12
 
Java Server Faces (JSF) - Basics
Java Server Faces (JSF) - BasicsJava Server Faces (JSF) - Basics
Java Server Faces (JSF) - Basics
BG Java EE Course
 
Lecture 5 JSTL, custom tags, maven
Lecture 5   JSTL, custom tags, mavenLecture 5   JSTL, custom tags, maven
Lecture 5 JSTL, custom tags, maven
Fahad Golra
 
TY.BSc.IT Java QB U5&6
TY.BSc.IT Java QB U5&6TY.BSc.IT Java QB U5&6
TY.BSc.IT Java QB U5&6
Lokesh Singrol
 
Jdbc
JdbcJdbc
Jsp ppt
Jsp pptJsp ppt
Jsp ppt
Vikas Jagtap
 
Lecture 1: Introduction to JEE
Lecture 1:  Introduction to JEELecture 1:  Introduction to JEE
Lecture 1: Introduction to JEE
Fahad Golra
 
Jsf presentation
Jsf presentationJsf presentation
Jsf presentation
Ashish Gupta
 
24 collections framework interview questions
24 collections framework interview questions24 collections framework interview questions
24 collections framework interview questions
Arun Vasanth
 
Struts,Jsp,Servlet
Struts,Jsp,ServletStruts,Jsp,Servlet
Struts,Jsp,Servlet
dasguptahirak
 
TY.BSc.IT Java QB U5
TY.BSc.IT Java QB U5TY.BSc.IT Java QB U5
TY.BSc.IT Java QB U5
Lokesh Singrol
 
JSP - Part 2 (Final)
JSP - Part 2 (Final) JSP - Part 2 (Final)
JSP - Part 2 (Final)
Hitesh-Java
 
Lecture 3: Servlets - Session Management
Lecture 3:  Servlets - Session ManagementLecture 3:  Servlets - Session Management
Lecture 3: Servlets - Session Management
Fahad Golra
 
Spring - Part 4 - Spring MVC
Spring - Part 4 - Spring MVCSpring - Part 4 - Spring MVC
Spring - Part 4 - Spring MVC
Hitesh-Java
 
Javatwo2012 java frameworkcomparison
Javatwo2012 java frameworkcomparisonJavatwo2012 java frameworkcomparison
Javatwo2012 java frameworkcomparison
Jini Lee
 
Java EE 7 - Overview and Status
Java EE 7  - Overview and StatusJava EE 7  - Overview and Status
Java EE 7 - Overview and Status
Java Usergroup Berlin-Brandenburg
 
Spring design-juergen-qcon
Spring design-juergen-qconSpring design-juergen-qcon
Spring design-juergen-qconYiwei Ma
 
Contextual Dependency Injection for Apachecon 2010
Contextual Dependency Injection for Apachecon 2010Contextual Dependency Injection for Apachecon 2010
Contextual Dependency Injection for Apachecon 2010Rohit Kelapure
 

What's hot (20)

JSP Technology I
JSP Technology IJSP Technology I
JSP Technology I
 
Lecture 9 - Java Persistence, JPA 2
Lecture 9 - Java Persistence, JPA 2Lecture 9 - Java Persistence, JPA 2
Lecture 9 - Java Persistence, JPA 2
 
Java EE Introduction
Java EE IntroductionJava EE Introduction
Java EE Introduction
 
Java Server Faces (JSF) - Basics
Java Server Faces (JSF) - BasicsJava Server Faces (JSF) - Basics
Java Server Faces (JSF) - Basics
 
Lecture 5 JSTL, custom tags, maven
Lecture 5   JSTL, custom tags, mavenLecture 5   JSTL, custom tags, maven
Lecture 5 JSTL, custom tags, maven
 
TY.BSc.IT Java QB U5&6
TY.BSc.IT Java QB U5&6TY.BSc.IT Java QB U5&6
TY.BSc.IT Java QB U5&6
 
Jdbc
JdbcJdbc
Jdbc
 
Jsp ppt
Jsp pptJsp ppt
Jsp ppt
 
Lecture 1: Introduction to JEE
Lecture 1:  Introduction to JEELecture 1:  Introduction to JEE
Lecture 1: Introduction to JEE
 
Jsf presentation
Jsf presentationJsf presentation
Jsf presentation
 
24 collections framework interview questions
24 collections framework interview questions24 collections framework interview questions
24 collections framework interview questions
 
Struts,Jsp,Servlet
Struts,Jsp,ServletStruts,Jsp,Servlet
Struts,Jsp,Servlet
 
TY.BSc.IT Java QB U5
TY.BSc.IT Java QB U5TY.BSc.IT Java QB U5
TY.BSc.IT Java QB U5
 
JSP - Part 2 (Final)
JSP - Part 2 (Final) JSP - Part 2 (Final)
JSP - Part 2 (Final)
 
Lecture 3: Servlets - Session Management
Lecture 3:  Servlets - Session ManagementLecture 3:  Servlets - Session Management
Lecture 3: Servlets - Session Management
 
Spring - Part 4 - Spring MVC
Spring - Part 4 - Spring MVCSpring - Part 4 - Spring MVC
Spring - Part 4 - Spring MVC
 
Javatwo2012 java frameworkcomparison
Javatwo2012 java frameworkcomparisonJavatwo2012 java frameworkcomparison
Javatwo2012 java frameworkcomparison
 
Java EE 7 - Overview and Status
Java EE 7  - Overview and StatusJava EE 7  - Overview and Status
Java EE 7 - Overview and Status
 
Spring design-juergen-qcon
Spring design-juergen-qconSpring design-juergen-qcon
Spring design-juergen-qcon
 
Contextual Dependency Injection for Apachecon 2010
Contextual Dependency Injection for Apachecon 2010Contextual Dependency Injection for Apachecon 2010
Contextual Dependency Injection for Apachecon 2010
 

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

Jsf2 overview
Jsf2 overviewJsf2 overview
Jsf2 overview
sohan1234
 
Development of web apps based on JSF (TU Vienna)
Development of web apps based on JSF (TU Vienna)Development of web apps based on JSF (TU Vienna)
Development of web apps based on JSF (TU Vienna)
blahap
 
Spring MVC introduction HVA
Spring MVC introduction HVASpring MVC introduction HVA
Spring MVC introduction HVA
Peter Maas
 
Introduction to ejb and struts framework
Introduction to ejb and struts frameworkIntroduction to ejb and struts framework
Introduction to ejb and struts framework
s4al_com
 
Mvc15 (1)
Mvc15 (1)Mvc15 (1)
Mvc15 (1)
sloumaallagui1
 
ASP.NET MVC as the next step in web development
ASP.NET MVC as the next step in web developmentASP.NET MVC as the next step in web development
ASP.NET MVC as the next step in web developmentVolodymyr Voytyshyn
 
Java Web Programming [1/9] : Introduction to Web Application
Java Web Programming [1/9] : Introduction to Web ApplicationJava Web Programming [1/9] : Introduction to Web Application
Java Web Programming [1/9] : Introduction to Web Application
IMC Institute
 
Frameworks in java
Frameworks in javaFrameworks in java
Frameworks in java
Darshan Patel
 
Month 2 report
Month 2 reportMonth 2 report
Month 2 report
PRIYANKA FNU
 
Spring mvc 2.0
Spring mvc 2.0Spring mvc 2.0
Spring mvc 2.0
Rudra Garnaik, PMI-ACP®
 
Web Component Development with Servlet and JSP Technologies Unit 01
Web Component Development with Servlet and JSP Technologies Unit 01Web Component Development with Servlet and JSP Technologies Unit 01
Web Component Development with Servlet and JSP Technologies Unit 01
Prashanth Shivakumar
 
Struts & spring framework issues
Struts & spring framework issuesStruts & spring framework issues
Struts & spring framework issues
Prashant Seth
 
My04_MVC.pdf
My04_MVC.pdfMy04_MVC.pdf
My04_MVC.pdf
Alfas3
 

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

Jsf Framework
Jsf FrameworkJsf Framework
Jsf Framework
 
Jsf2 overview
Jsf2 overviewJsf2 overview
Jsf2 overview
 
Development of web apps based on JSF (TU Vienna)
Development of web apps based on JSF (TU Vienna)Development of web apps based on JSF (TU Vienna)
Development of web apps based on JSF (TU Vienna)
 
Spring MVC introduction HVA
Spring MVC introduction HVASpring MVC introduction HVA
Spring MVC introduction HVA
 
Introduction to ejb and struts framework
Introduction to ejb and struts frameworkIntroduction to ejb and struts framework
Introduction to ejb and struts framework
 
Mvc15 (1)
Mvc15 (1)Mvc15 (1)
Mvc15 (1)
 
ASP.NET MVC as the next step in web development
ASP.NET MVC as the next step in web developmentASP.NET MVC as the next step in web development
ASP.NET MVC as the next step in web development
 
MVC
MVCMVC
MVC
 
Asp.Net MVC3 - Basics
Asp.Net MVC3 - BasicsAsp.Net MVC3 - Basics
Asp.Net MVC3 - Basics
 
Weblogic
WeblogicWeblogic
Weblogic
 
Java Web Programming [1/9] : Introduction to Web Application
Java Web Programming [1/9] : Introduction to Web ApplicationJava Web Programming [1/9] : Introduction to Web Application
Java Web Programming [1/9] : Introduction to Web Application
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Frameworks in java
Frameworks in javaFrameworks in java
Frameworks in java
 
Jinal desai .net
Jinal desai .netJinal desai .net
Jinal desai .net
 
Month 2 report
Month 2 reportMonth 2 report
Month 2 report
 
Struts Basics
Struts BasicsStruts Basics
Struts Basics
 
Spring mvc 2.0
Spring mvc 2.0Spring mvc 2.0
Spring mvc 2.0
 
Web Component Development with Servlet and JSP Technologies Unit 01
Web Component Development with Servlet and JSP Technologies Unit 01Web Component Development with Servlet and JSP Technologies Unit 01
Web Component Development with Servlet and JSP Technologies Unit 01
 
Struts & spring framework issues
Struts & spring framework issuesStruts & spring framework issues
Struts & spring framework issues
 
My04_MVC.pdf
My04_MVC.pdfMy04_MVC.pdf
My04_MVC.pdf
 

More from IMC Institute

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

More from IMC Institute (20)

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

Recently uploaded

The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
CatarinaPereira64715
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 

Recently uploaded (20)

The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 

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