SlideShare une entreprise Scribd logo
1  sur  41
Server-side  Web Programming Lecture 9:  Shopping Carts and the Model-View-Control Architecture
Modeling the Business Process ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Model-View-Control Architecture ,[object Object],[object Object],[object Object],[object Object],request Control servlet View JSP response View JSP View JSP Classes that  model  business process Store data Access and display data Database
Model Classes and Session ,[object Object],[object Object],[object Object],All session data Session ID =  fieh4K39Rdk … … … … Session data name email “ Fred” “ fred@aolrock”
Model Classes and Session ,[object Object],[object Object],[object Object],All session data Session ID =  fieh4K39Rdk … … … … Session data customerInfo cart Customer object Cart object
Model Class Properties ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Example Customer Class
Creating Support Classes ,[object Object],[object Object]
Creating Support Classes ,[object Object],[object Object],[object Object],[object Object]
Using Model Classes ,[object Object],[object Object],[object Object],[object Object]
Using Model Classes ,[object Object],[object Object],[object Object],[object Object]
Using Model Classes ,[object Object],[object Object],[object Object],[object Object],[object Object]
Business Model Objects ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Business Model Example ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Order Class
Validation in Servlet
Getting Cost in JSP
Shopping Carts ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Example “Bookstore” Cart ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Cart object Session ID: 98A6F401BC6393 Item object Code: 0001 Title: Murach's Java Servlets    and JSP Price: $31.19  Quantity: 1 Item object Code: 0003 Title: HTML and XHTML    Pocket Reference   Price: $10.39   Quantity: 2
“ Bookstore” Cart Methods ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Used together to loop through and show  all  Items on “shopping cart” page
“ Bookstore” Cart Methods
“ Bookstore” Item Methods ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
“ Bookstore” Item Methods
Displaying Cart Contents ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Inside table Size of loop Get ith item object Get its fields Inside loop, create new table row showing those fields
Displaying Cart Contents
Displaying Cart Contents
Adding to the Cart in a Servlet ,[object Object],[object Object],[object Object]
Adding to the Cart in a Servlet ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Adding to the Cart in a Servlet
Adding to the Cart in a Servlet ,[object Object],[object Object],[object Object]
Embedded Forms in Cart Pages ,[object Object],[object Object]
Embedded Forms in Cart Pages ,[object Object],[object Object],[object Object],[object Object]
Simple Removal Servlet
Hidden Form Elements ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Hidden Form Elements productCode read in from Cart in session and stored in hidden element inside removal form
Quantity Update Example
Quantity Update Example Pass productCode as hidden field so servlet knows which Item to change Also pass new quantity entered by user
Passing Data using Links ,[object Object],[object Object]
Passing Data using Links ,[object Object],[object Object],[object Object],[object Object],[object Object],Submit request to the servlet The ‘?’ indicates form parameters Each passed as a name=value pair separated by ‘&’
Passing Data using Links

Contenu connexe

Similaire à Lecture9

4 introduction-php-mvc-cakephp-m4-controllers-slides
4 introduction-php-mvc-cakephp-m4-controllers-slides4 introduction-php-mvc-cakephp-m4-controllers-slides
4 introduction-php-mvc-cakephp-m4-controllers-slides
MasterCode.vn
 
Spring Data JPA in detail with spring boot
Spring Data JPA in detail with spring bootSpring Data JPA in detail with spring boot
Spring Data JPA in detail with spring boot
rinky1234
 
Struts Intro Course(1)
Struts Intro Course(1)Struts Intro Course(1)
Struts Intro Course(1)
wangjiaz
 
Database Refactoring Sreeni Ananthakrishna 2006 Nov
Database Refactoring Sreeni Ananthakrishna 2006 NovDatabase Refactoring Sreeni Ananthakrishna 2006 Nov
Database Refactoring Sreeni Ananthakrishna 2006 Nov
melbournepatterns
 

Similaire à Lecture9 (20)

4 introduction-php-mvc-cakephp-m4-controllers-slides
4 introduction-php-mvc-cakephp-m4-controllers-slides4 introduction-php-mvc-cakephp-m4-controllers-slides
4 introduction-php-mvc-cakephp-m4-controllers-slides
 
Cart creation-101217222728-phpapp01
Cart creation-101217222728-phpapp01Cart creation-101217222728-phpapp01
Cart creation-101217222728-phpapp01
 
Magento Indexes
Magento IndexesMagento Indexes
Magento Indexes
 
Shopify Theme Building Workshop
Shopify Theme Building WorkshopShopify Theme Building Workshop
Shopify Theme Building Workshop
 
Spring Data JPA in detail with spring boot
Spring Data JPA in detail with spring bootSpring Data JPA in detail with spring boot
Spring Data JPA in detail with spring boot
 
Catalog display
Catalog displayCatalog display
Catalog display
 
Spring Data JPA USE FOR CREATING DATA JPA
Spring Data JPA USE FOR CREATING DATA  JPASpring Data JPA USE FOR CREATING DATA  JPA
Spring Data JPA USE FOR CREATING DATA JPA
 
Struts Intro Course(1)
Struts Intro Course(1)Struts Intro Course(1)
Struts Intro Course(1)
 
Jazz
JazzJazz
Jazz
 
Lecture1
Lecture1Lecture1
Lecture1
 
Nj 09 T2 David Frischknecht
Nj 09 T2 David FrischknechtNj 09 T2 David Frischknecht
Nj 09 T2 David Frischknecht
 
How to develop a gateway service using code based implementation
How to develop a gateway service using code based implementationHow to develop a gateway service using code based implementation
How to develop a gateway service using code based implementation
 
Share Point
Share PointShare Point
Share Point
 
Sap enhanced functions
Sap enhanced functionsSap enhanced functions
Sap enhanced functions
 
Angular 2 Essential Training
Angular 2 Essential Training Angular 2 Essential Training
Angular 2 Essential Training
 
Database Refactoring Sreeni Ananthakrishna 2006 Nov
Database Refactoring Sreeni Ananthakrishna 2006 NovDatabase Refactoring Sreeni Ananthakrishna 2006 Nov
Database Refactoring Sreeni Ananthakrishna 2006 Nov
 
Itemscript, a specification for RESTful JSON integration
Itemscript, a specification for RESTful JSON integrationItemscript, a specification for RESTful JSON integration
Itemscript, a specification for RESTful JSON integration
 
ASP.NET 10 - Data Controls
ASP.NET 10 - Data ControlsASP.NET 10 - Data Controls
ASP.NET 10 - Data Controls
 
Taking Apex and Visualforce Above and Beyond
Taking Apex and Visualforce Above and BeyondTaking Apex and Visualforce Above and Beyond
Taking Apex and Visualforce Above and Beyond
 
Designing CakePHP plugins for consuming APIs
Designing CakePHP plugins for consuming APIsDesigning CakePHP plugins for consuming APIs
Designing CakePHP plugins for consuming APIs
 

Plus de Châu Thanh Chương (20)

Lecture19
Lecture19Lecture19
Lecture19
 
Lecture18
Lecture18Lecture18
Lecture18
 
Lecture17
Lecture17Lecture17
Lecture17
 
Lecture16
Lecture16Lecture16
Lecture16
 
Lecture15
Lecture15Lecture15
Lecture15
 
Lecture14
Lecture14Lecture14
Lecture14
 
Lecture13
Lecture13Lecture13
Lecture13
 
Lecture12
Lecture12Lecture12
Lecture12
 
Lecture11
Lecture11Lecture11
Lecture11
 
Lecture10
Lecture10Lecture10
Lecture10
 
Lecture8
Lecture8Lecture8
Lecture8
 
Lecture7 pattern
Lecture7 patternLecture7 pattern
Lecture7 pattern
 
Lecture6
Lecture6Lecture6
Lecture6
 
Lecture5
Lecture5Lecture5
Lecture5
 
Lecture4
Lecture4Lecture4
Lecture4
 
Lecture3
Lecture3Lecture3
Lecture3
 
Lecture2
Lecture2Lecture2
Lecture2
 
Lecture19
Lecture19Lecture19
Lecture19
 
7 data management design
7 data management design7 data management design
7 data management design
 
6 class design
6 class design6 class design
6 class design
 

Dernier

Dernier (20)

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 

Lecture9

Notes de l'éditeur

  1. Business logic: quy trinh nghiep vu