Web Software Model CS 4640 Programming Languages for Web Applications [Robert W. Sebesta, “Programming the World Wide Web]
Web Applications Are user interactive software programs, deployed on a web server, accessed via a web browser Use enabling technologies to make web site contents dynamic allow users of the system to implement business logic on the server Let users affect state on the server Constructed from diverse, distributed, and dynamically generated web components Web components are software modules that implement different parts of the application’s functionality An enabling technology makes web pages interactive and responsive to user input CS 4640
How User Interact With Web Apps http://www.virginia.edu/ Web server Web application HTTP Request PHPs Java servlets JSPs Usability Web component1 Web component2 Web componentn Request HTML JS CSS Web client DB Response HTTP Response HTTP request / response cycle CS 4640
How the Web Software Works Browser To server Java servlet (idProgram) Browser To client CS 4640
Server Side Processing data HTTP Request XAMPP and Tomcat Client UI implemented in a browser Server Web server Container engine Program components HTTP Response HTML CS 4640
Execution Overview Response back to requestor Incoming request Server 8 1 HTTP Request HTTP Response 2 7 Web server Request / Response Objects 3 Modified Response Object 6 Container engine Create thread / call method 4 Return 5 Program component CS 4640
Page Centric and Dispatcher Designs Page-centric (client-server) Requests are made to a main component, and the main component response to clients Dispatcher (N-tier) Requests are sent to a dispatcher that then forward the requests to another component The goal is to separate logic from presentation and to separate as many concerns in the logic as possible CS 4640
(Client requests are intercepted here) Page-centric Design Server Web client Main component (Client requests are intercepted here) Component (data) Uses or instantiates Request Response Web client Database Web client CS 4640
Dispatcher Design Server Request Response Dispatcher Database Web client Web client Request Response Dispatcher Database Component presentation Data Business processing Web client Usually use forward Component presentation Data Component presentation CS 4640
Model View Controller An abstraction frequently used in web app design Provide a way to divide the responsibilities of objects Decreases coupling between objects and layers (supports easier maintenance) Help divide the work (supports development expertise areas) CS 4640
Model View Controller (2) data structures HTML / JSP / frontend Comppnents Model method calls Encapsulates application state Responds to state queries Exposes application functionality Notifies views of changes events state change state query change notification View Controller view select Renders the model Requests updates from the model Sends user inputs to controller Allows controller to select view Defines application behavior Maps user actions to model updates Selects a view for response One view for each function user input * Graphic from Designing Enterprise Applications with the Java 2 Platform, Enterprise Edition, Nicholas Kassem et al., October 2000 CS 4640
Session Management HTTP client-server communication is connnectionless As soon as the request is made and fulfilled, the connection is terminated Communication is simple and resistant to network problems Stateless property Server send a request response a request CS 4640
We will come back to this later … Session Management (2) How can servers keep track of state of different clients? Session : A single coherent use of the system by the same user Example : shopping carts Cookies : A string of characters that a web server places on a browser’s client to keep track of a session Usually used as an index into a table (dictionary) on the server Most dictionaries expire after a period of time (15 to 30 minutes) Additional mechanisms URL rewriting Hidden form control We will come back to this later … CS 4640
Additional Web Features User’s ability to control web application via web browser features index login browse record_add submit a form post (userid , password) redirect record_insert post (name, category, content) back component simple link transition form link transition redirect transition operational transition CS 4640
Additional Web Features (2) Identifying web application resources with URLs index login browse record_add submit a form post (userid , password) redirect record_insert post (name, category, content) back operational transition component simple link transition form link transition redirect transition userlogin.jsp CS 4640
Additional Web Features (3) Communication among web components depending on requests through the HTTP index login browse record_add submit a form post (userid , password) redirect record_insert post (name, category, content) back component simple link transition form link transition redirect transition operational transition get CS 4640
Additional Web Features (4) Control connections: forward, include, redirect index login browse record_add submit a form post (userid , password) redirect record_insert post (name, category, content) back component simple link transition form link transition redirect transition operational transition forward CS 4640
Additional Web Features (5) State scope of web components application session request forward page request Client 1 page request forward request Client 2 request page [Jeff Offutt, Scope and Handling State] CS 4640
Summary Web Applications The major difference is deployment Software is deployed across the Web using HTTP Other deployment methods include bundling, shrink-wrapping, embedding, and contracting New software technologies New conceptual language constructs for programming Integration Data management Control connections These differences affect every aspect of how to engineer high quality software CS 4640