Download presentation
Presentation is loading. Please wait.
Published byGeorgina Hawkins Modified over 9 years ago
1
Chapter 9 Web Application Design
2
Objectives Describe the MVC design pattern as used with Web applications Explain the role and responsibilities of each MVC component Map MVC components to the servlet webapp file structure Describe a design for a scalable controller
3
Webapp Design Any complex system must begin with a cohesive fundamental design Multiple aspects of webapp design –Product Design: how the overall application will function, including: –Interaction (User-Interface) Design: The operation, look, and feel of the user interface –Software Design: The required software components and how they will interact
4
Design Patterns A software design pattern is an abstraction of some commonly used software design This abstraction includes enough information to enable reuse of the pattern with new applications A pattern for architectural (high-level) design is also called an architectural style
5
Model-View-Controller Many webapps are based on the well- known model-view-controller design pattern The MVC pattern specifies the responsibilities of three major components, and the nature of their interactions View Model Controller
6
MVC Component Responsibilities View: Present the user interface Model: Maintain the application state Controller: Handle user actions
7
Model Role The Model maintains the application state, which includes: –persistent information stored in databases –current information related to active sessions Responsibilities include: –applying rules / transactions to modify state –providing information to the View as required –taking instructions from the Controller
8
View Role The View presents a user interface, including information and transactional controls Responsibilities include: –Present required information to user –Request data from Model as needed (to create displays for the user)
9
Controller Role The Controller handles user actions Responsibilities include: –Handle user actions –Validate user requests (correctness, completeness) –Invoke Model components to handle requested transactions –Set the appropriate next View perspective
10
MVC Component Responsibilities View: Present the user interface Model: Maintain the application state Controller: Handle user actions
11
MVC in Action 1.User requests "login" option; Controller sets "login.jsp" as the next view. 2.User enters credentials; Controller invokes LoginHandler to handle transcation 3.etc. View Controller Model
12
Servlet Webapp File Configuration View components (html, jsp, images, etc.) go in the root directory Controller components generally go in the servlet package Model components generally go in the bean package A common package may be used to include shared classes bean common servlet
13
Scalable MVC Framework A more scalable framework can be created by defining each transaction in a configuration file New transactions can be created by adding View and Model components as needed, and modify the configuration login bean.LoginHandler userid password login menu.jsp login.jsp </control-mappings
14
Review MVC Design Pattern MVC Components Servlet webapp file structure Scalable MVC Framework
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.