Saving State on the WWW. The Issue  Connections on the WWW are stateless  Every time a link is followed is like the first time to the server — it has.

Slides:



Advertisements
Similar presentations
DT228/3 Web Development WWW and Client server model.
Advertisements

Copyright 2004 Monash University IMS5401 Web-based Systems Development Topic 2: Elements of the Web (g) Interactivity.
Browsers and Servers CGI Processing Model ( Common Gateway Interface ) © Norman White, 2013.
6/10/2015Cookies1 What are Cookies? 6/10/2015Cookies2 How did they do that?
Servlets and a little bit of Web Services Russell Beale.
How the web works: HTTP and CGI explained
1 CS6320 – Why Servlets? L. Grewe 2 What is a Servlet? Servlets are Java programs that can be run dynamically from a Web Server Servlets are Java programs.
Definitions, Definitions, Definitions Lead to Understanding.
Session Management A290/A590, Fall /25/2014.
Application Layer  We will learn about protocols by examining popular application-level protocols  HTTP  FTP  SMTP / POP3 / IMAP  Focus on client-server.
1 The World Wide Web. 2  Web Fundamentals  Pages are defined by the Hypertext Markup Language (HTML) and contain text, graphics, audio, video and software.
2/9/2004 Web and HTTP February 9, /9/2004 Assignments Due – Reading and Warmup Work on Message of the Day.
Hypertext Transport Protocol CS Dick Steflik.
CGI Programming: Part 1. What is CGI? CGI = Common Gateway Interface Provides a standardized way for web browsers to: –Call programs on a server. –Pass.
SE-2840 Dr. Mark L. Hornick1 Java Servlet-based web apps Servlet Architecture.
Cookies COEN 351 E-commerce Security. Client / Session Identification HTTP does not maintain state. State Information can be passed using: HTTP Headers.
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
 A cookie is a piece of text that a Web server can store on a user's hard disk.  Cookie data is simply name-value pairs stored on your hard disk by.
Sys Prog & Scripting - HW Univ1 Systems Programming & Scripting Lecture 15: PHP Introduction.
1 ‘Dynamic’ Web Pages So far, we have developed ‘static’ web-pages, e.g., cv.html, repair.html and order.html. There is often a requirement to produce.
1 Web Developer & Design Foundations with XHTML Chapter 6 Key Concepts.
_______________________________________________________________________________________________________________ E-Commerce: Fundamentals and Applications1.
FORESEC Academy FORESEC Academy Security Essentials (II)
Computer Concepts 2014 Chapter 7 The Web and .
Chapter 9 Using Perl for CGI Programming. Computation is required to support sophisticated web applications Computation can be done by the server or the.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
CHAPTER 12 COOKIES AND SESSIONS. INTRO HTTP is a stateless technology Each page rendered by a browser is unrelated to other pages – even if they are from.
Comp2513 Forms and CGI Server Applications Daniel L. Silver, Ph.D.
About Dynamic Sites (Front End / Back End Implementations) by Janssen & Associates Affordable Website Solutions for Individuals and Small Businesses.
IT533 Lectures Session Management in ASP.NET. Session Tracking 2 Personalization Personalization makes it possible for e-businesses to communicate effectively.
CP476 Internet Computing Lecture 5 : HTTP, WWW and URL 1 Lecture 5. WWW, HTTP and URL Objective: to review the concepts of WWW to understand how HTTP works.
2: Application Layer1 CS 4244: Internet Software Development Dr. Eli Tilevich.
Web application architecture
JavaScript, Fourth Edition
CS453: State in Web Applications (Part 1) State in General Sessions (esp. in PHP) Prof. Tom Horton.
Chapter 8 Cookies And Security JavaScript, Third Edition.
Web Application Development * These slides have been adapted and modified from CoreServlets course material (Marty Hall) and LUMS cs391 (Umair Javed).
Chapter 6 Server-side Programming: Java Servlets
ITCS373: Internet Technology Lecture 5: More HTML.
_______________________________________________________________________________________________________________ E-Commerce: Fundamentals and Applications1.
STATE MANAGEMENT.  Web Applications are based on stateless HTTP protocol which does not retain any information about user requests  The concept of state.
1 MSCS 237 Overview of web technologies (A specific type of distributed systems)
Web Database Programming Week 7 Session Management & Authentication.
Maintaining Application State MIS3502: Application Integration and Evaluation Paul Weinberg Presentation by David Schuff.
Cookies COEN 351 E-commerce Security. Client / Session Identification HTTP Headers Client IP Address HTTP User Login FAT URLs Cookies.
CP476 Internet Computing CGI1 Cookie –Cookie is a mechanism for a web server recall info of accessing of a client browser –A cookie is an object sent by.
2007cs Servers on the Web. The World-Wide Web 2007 cs CSS JS HTML Server Browser JS CSS HTML Transfer of resources using HTTP.
1 WWW. 2 World Wide Web Major application protocol used on the Internet Simple interface Two concepts –Point –Click.
ECMM6018 Enterprise Networking for Electronic Commerce Tutorial 7
Fall 2000C.Watters1 World Wide Web and E-Commerce Clients & Client Side Processing.
Web Technologies Lecture 8 Server side web. Client Side vs. Server Side Web Client-side code executes on the end-user's computer, usually within a web.
JS (Java Servlets). Internet evolution [1] The internet Internet started of as a static content dispersal and delivery mechanism, where files residing.
Fall 2000C.Watters1 World Wide Web and E-Commerce Servers & Server Side Processing.
WEB SERVER SOFTWARE FEATURE SETS
1 State and Session Management HTTP is a stateless protocol – it has no memory of prior connections and cannot distinguish one request from another. The.
©SoftMooreSlide 1 Session Tracking with Servlets.
1 PHP HTTP After this lecture, you should be able to know: How to create and process web forms with HTML and PHP. How to create and process web forms with.
COSC 2328 – Web Programming.  PHP is a server scripting language  It’s widely-used and free  It’s an alternative to Microsoft’s ASP and Ruby  PHP.
1 UNIT 13 The World Wide Web. Introduction 2 Agenda The World Wide Web Search Engines Video Streaming 3.
1 UNIT 13 The World Wide Web. Introduction 2 The World Wide Web: ▫ Commonly referred to as WWW or the Web. ▫ Is a service on the Internet. It consists.
Distributed Web Systems Cookies and Session Tracking Lecturer Department University.
Managing State Chapter 13.
WWW and HTTP King Fahd University of Petroleum & Minerals
Web Software Model CS 4640 Programming Languages for Web Applications
What is Cookie? Cookie is small information stored in text file on user’s hard drive by web server. This information is later used by web browser to retrieve.
Client / Session Identification Cookies
Chapter 27 WWW and HTTP.
Session Tracking Techniques
Back end Development CS Programming Languages for Web Applications
Back end Development CS Programming Languages for Web Applications
Presentation transcript:

Saving State on the WWW

The Issue  Connections on the WWW are stateless  Every time a link is followed is like the first time to the server — it has no memory for connections

Why Bother To Fix This? By saving state we can… Save configuration information between sessions Save configuration information between sessions Make adaptive websites (change themselves to suit user’s behaviour) Make adaptive websites (change themselves to suit user’s behaviour) Enable e-commerce applications (shopping carts) Enable e-commerce applications (shopping carts) Violate users’ privacy by tracking which websites and webpages they visit Violate users’ privacy by tracking which websites and webpages they visit

Saving State In General

Methods of Saving State  Cookies  Session-level authentication  form s  URL Rewriting

Method 1: Cookies  Basic idea Client stores data for the server Client stores data for the server Client sends data to server with each request Client sends data to server with each request  Details (Version 0) Required fields: name=value Required fields: name=value Optional fields: domain, path, secure, expires Optional fields: domain, path, secure, expires Size: maximum 4 kilobytes Size: maximum 4 kilobytes Number: maximum 1024 cookies Number: maximum 1024 cookies

Aside: Cookie Concept  Cookie is a computing term from long ago.  According to The New Hacker’s Dictionary: Something passed between subroutines or programs that enables the receiver to do something useful Something passed between subroutines or programs that enables the receiver to do something useful The thing being passed is opaque to the sender (e.g. time_t type C libraries use) The thing being passed is opaque to the sender (e.g. time_t type C libraries use) Cookies are also small Cookies are also small  ‘The phrase “it hands you a magic cookie” means it returns a result whose contents are not defined but which can be passed back to the same or some other program later.’ [source for quote at end]

Cookie Examples Examples at course website Examples at course website time1.cgi vs. time2.cgi time1.cgi vs. time2.cgi Compare form method with cookie method cookie-colour cookie-colour One program to write cookies One program to write cookies One program to read cookies One program to read cookies Use env.cgi to see cookies in headers Use env.cgi to see cookies in headers

Method 2: Session-level Authentication  See §12.2 (Basic Authentication) in HTTP: The Definitive Guide by David Gourley & Brian Totty, © 2002 by O'Reilly & Associates, Inc. (ISBN: ) Basic AuthenticationBasic Authentication  Session (from ISO Reference Model) Logical communication between two network end points Logical communication between two network end points Sessions are composed of requests and responses that occur between applications in different network hosts. Sessions are composed of requests and responses that occur between applications in different network hosts. In browser terms a session is the longevity of the O/S process In browser terms a session is the longevity of the O/S process

The Steps of Basic Authentication 1. Browser requests resource from server application  usually with GET protocol 2. Server replies with code 401 (authorization required) 3. Browser prompts user  for name & password 4. Browser resends request including the name & password (in the network header) H Every time the browser makes a request for that resource it will send the name & password, until the end of the session H The name & password are like a cookie that is stored in RAM H Because they are in RAM they will be forgotten when the browser quits (i.e., at the end of the session)

Method 3: form s with hidden fields  We usually pull webpages in from a server  Forms are for pushing data to the server  To use forms we need to use CGI protocol CGI = common gateway interface CGI = common gateway interface An application layer protocol that allows client to send data to the server An application layer protocol that allows client to send data to the server

Two form Methods method=“get”method=“post”  Data is part of URL  Data is not part of URL  Only used for simple requests (e.g. search engine queries)  Can be used for file upload  Conceptually: a query of a database  Conceptually: an alteration to a database See form examples online form examples form examples

Saving State With form s  Hidden post & simple get Hidden post & simple get Hidden post & simple get  Did you see the hidden field?  Did you see the hidden data?  That’s one way of saving state:  Placing the data in a form so that every time the form is submitted (sent to the server) the data is sent too Examples using CGI program to generate a form Examples using CGI program to generate a form  Loan.cgi and multi-page.cgi Loan.cgi and multi-page.cgi Loan.cgi and multi-page.cgi

Essence of State Saving Using forms Browser CGI program(s) form in HTML file State info. State info.

Essence of State Saving Using form s  There must be an uninterrupted sequence of request/responses pairs from the browser to a CGI program (or programs)  The state must be represented in the form, and represented in the form, and recognized by the CGI program(s) recognized by the CGI program(s)  The CGI program(s) must encode the state in the form

Essence of State Saving Using forms

This diagram is for a single CGI program and a single form, but the same thing could be done with multiple programs & forms

Method 4: Servlets & URL Rewriting  Recall that method=“get” form s pass their data in the URL  These URLS are designed to be cached You don’t need a browser that can understand form s to use them You don’t need a browser that can understand form s to use them You can just type them in like any other web address You can just type them in like any other web address

URL Rewriting Explained  So why not put the state information from method=“get” form s in the href of every anchor Instead of <a href="foo.html" >click here do ?session=… <a href="foo.html?session=…" >click here

Servlets (1 of 2)  Many users dislike long URLs — they are hard to mail to friends & look ugly  Some browser software don’t support cookies — and many users have such support disabled  Wouldn’t it be great if your server would use cookies when the client supported them, and URL rewriting when it didn’t?

Servlets (2 of 2)  Servlets (and other server-side software) do that!  Servlets are server-side programs written in Java  Other server-side technologies work the same way but are implemented in other languages See also Servlets lecture See also Servlets lecture

What Data Do We Pass?  But isn’t that a lot of state information to send back and forth?  Not really, because we don’t have to pass all of the data back and forth  We can pass a user or session ID and  the server will maintain a database keyed by those IDs

Resources  Cookie resources at course website Cookie resources Cookie resources  HTTP: The Definitive Guide in the e-book collection the e-book collectionthe e-book collection  Cookie examples at course website Cookie examples Cookie examples  SessionTrack servlet example at course website SessionTrack servlet example SessionTrack servlet example  Note that servlets are not always running at FCS

Bibliography 1.CS4173 Resource List 2.Web Protocols and Practice Balachander Krishnamurthy & Jennifer Rexford Addison-Wesley May 2001 © 2001 by AT&T Corp. (ISBN ) 3.HTTP: The Definitive Guide David Gourley & Brian Totty, with others David Gourley & Brian Totty, with others O'Reilly & Assoc. Sept O'Reilly & Assoc. Sept (ISBN ) (ISBN ) 4.The New Hacker’s Dictionary Eric S. Raymond (editor) Eric S. Raymond (editor) Online version used at Online version used at

Next…  CGI Programming