Introduction to Web Architecture SE2840 Web Application Design Jay - - PowerPoint PPT Presentation

introduction to web architecture
SMART_READER_LITE
LIVE PREVIEW

Introduction to Web Architecture SE2840 Web Application Design Jay - - PowerPoint PPT Presentation

Introduction to Web Architecture SE2840 Web Application Design Jay Urbain, PhD Credits: See last slide for references Contact info Jay Urbain, PhD email: urbain@msoe.edu Office hours: http://jayurbain.com/msoe Course home:


slide-1
SLIDE 1

Introduction to Web Architecture

SE2840 Web Application Design Jay Urbain, PhD Credits: See last slide for references

slide-2
SLIDE 2
slide-3
SLIDE 3

3

Contact info

  • Jay Urbain, PhD
  • email: urbain@msoe.edu
  • Office hours: http://jayurbain.com/msoe
  • Course home: http://jayurbain.com/msoe/se2840
  • Course outline: http://jayurbain.com/msoe/se2840/outline.html
  • Office: L-345
  • Cell: 414-745-5102
slide-4
SLIDE 4

Things we’ll cover in this course:

  • Basic WWW architecture: ReST, MVC (server-side, client-side)
  • HTML5 and CSS for web page content and appearance
  • Client-side JavaScript for validating forms and modifying

content/appearance of web pages

  • Ajax for efficient client-server interactions
  • jQuery for efficient DOM queries
  • Bootstrap for styling and cross-platform support
  • Data driven web applications – JavaScript|Python|Java
  • Modern JS framworks – Mongo, Express, Angular, NodeJS

(MEAN)

  • Web services
  • Highly interactive single page apps (Angular)
  • Security, privacy and confidentiality in website design

4

slide-5
SLIDE 5

Prerequisites:

Core programming skills: data structures, threading, IPC – This is all material you should have from CS2852 and CS2911

5

slide-6
SLIDE 6

6

Labs

  • Web page design using standard HTML/CSS
  • Client-side scripting using Javascript/Ajax
  • DOM Scripting and Event Handling using JS and Bootstrap
  • Web services client with Bootstrap, jQuery, d3.js
  • Dynamic data driven web apps
  • Model-View-Controller application
  • End-to-end web-services application
  • NodeJS (JS) based web server
  • Angular dash board
slide-7
SLIDE 7

7

Grading (Course Policies)

  • Reference syllabus in course outline.
slide-8
SLIDE 8

Outline

  • Basic Web Architecture
  • HTML
  • URI
  • HTTP
  • Web Architecture Extension
  • Cookies
  • Database-driven Website Architecture
  • AJAX
  • Web Services
  • XML, JSON
  • NodeJS
  • Angular
slide-9
SLIDE 9

The World Wide Web

  • In 1989, Tim Berners-Lee suggested

a way to let all users, but particularly scientists, browse each

  • thers papers on the Internet.
  • Developed HTML, URLs, and HTTP.
slide-10
SLIDE 10

Basic Web Architecture

  • The traditional web is a client-server/two-tiered architecture:

– A web browser requests information content, – a web server transfers information to the client, – and the web browser displays the transferred information.

slide-11
SLIDE 11

Web Browser

  • An application for retrieving, presenting, and traversing

information resources.

– The primary purpose is to bring information resources to the user. – http://gs.statcounter.com/browser-market-share - October, 2017

slide-12
SLIDE 12

Web Browser

  • An application for retrieving, presenting, and traversing

information resources.

– The primary purpose is to bring information resources to the user.

Mobile Phone OS

slide-13
SLIDE 13
slide-14
SLIDE 14

Mobile Market Share

slide-15
SLIDE 15

Web Server

  • The term web server can mean a couple of things:

– A computer program that accepts HTTP requests and returns HTTP responses with optional data content. – A computer that runs a computer program as described above.

slide-16
SLIDE 16
slide-17
SLIDE 17
slide-18
SLIDE 18

HTML - HyperText Markup Language

  • HTML is the main markup

language for creating web pages and other information that can be displayed in a web browser.

  • Derived from SGML (Standard

Generalized Markup Language)

  • Document layout language

(not a programming language).

  • Defines structure and content
  • f Web pages.

Show example

slide-19
SLIDE 19

HTML - HyperText Markup Language

  • HTML consists of several key components, including

elements (and their attributes), character-based data types, character references, and entity references.

  • Another important component is the document type

declaration, which triggers standards mode rendering.

1) Experiment with HTML: http://www.w3schools.com/html/defaul t.asp 2) Save your HTML in a file with an ‘html’ extension. 3) Double-click your file to open in a browser.

slide-20
SLIDE 20

URI - Universal Resource Identifier

  • URI is a string of characters used to identify a Web resource.
  • Enables interaction with a resource over a network (e.g., the

WWW) using specific protocols.

  • URIs can be classified as locators (URLs), as names (URNs), or

both.

  • A uniform resource name (URN) functions like a person's name.

I.e., the URN defines an item's identity.

– E.g. The ISBN system for uniquely identifying books: ISBN 0-486-27557-4

  • A uniform resource locator (URL) resembles that person's street

address., and provides a method for finding it.

– E.g., file:///home/username/books/

URI Venn Diagram

slide-21
SLIDE 21

URI Reference

  • URL’s and URN’s are complementary: Identifying the

electronic book saved on a local hard disk.

  • URI Reference:

http://example.org/absolute/URI/with/absolute/path/to/resource.txt

  • Contains four distinct parts: the protocol, the machine name,

the directory path, and the file name.

– There are several kinds of schemes: file URLs, FTP URLs, and HTTP URLs.

slide-22
SLIDE 22

HTTP - HyperText Transfer Protocol

  • Application protocol for distributed, collaborative,

hypermedia information systems.

  • Represented as structured text.
  • Foundation of data communication for the Web.
  • Stateless, request/response client-server protocol.

i.e., HTTP client initiates a request.

  • Resources to be accessed by HTTP are identified using

Uniform Resource Identifiers (URIs).

slide-23
SLIDE 23

Request methods

  • HTTP defines eight methods indicating the desired action to be

performed on the identified resource. BOLDed methods are supported by most web sites. – HEAD – same as GET without message body – GET – requests specified resource – POST – requests the server accept the entity enclosed in the request. – PUT – requests the entity enclosed in the request be stored. – DELETE – delete the specified resource – TRACE – echoes back the received request to see if changes were made by intermediate servers. – OPTIONS – returns the HTTP methods that the server supports for the given URL. – CONNECT – converts request connection to TCP/IP tunnel, usually to support SSL-encryption for VPN.

slide-24
SLIDE 24

Safe methods

  • HEAD, GET, OPTIONS and TRACE are defined as safe (no side

effects).

  • POST, PUT and DELETE are intended for actions which may

cause side effects either on the server. Note: not always implemented this way!

slide-25
SLIDE 25

Status Codes

  • The first line of the HTTP response is called the status line.
  • The way the user agent handles the response primarily

depends on the code and secondarily on the response headers. – Success: 2xx – Redirection: 3xx – Client-Side Error: 4xx – Server-Side Error: 5xx

slide-26
SLIDE 26

HTTP session state

  • HTTP is a stateless protocol.
  • Hosts do not need to retain information about users

between requests.

  • Statelessness is a scalability property.
  • For example, when a host needs to customize the content of

a website for a user, the following methods can be used:

  • Solution:

– Cookies (client side key-value) – Sessions (server-side, persists during user’s interaction) – Hidden variables (form variable) – URL encoded parameters (such as

/index.php?session_id=some_unique_session_code)

slide-27
SLIDE 27

Sample HTTP Request and Response

  • Client request
  • Server response
slide-28
SLIDE 28

HTTP Request and Response with Telnet

$ telnet www.jayurbain.com 80 Trying 50.63.39.1... Connected to jayurbain.com. Escape character is '^]'. GET /msoe/index.html HTTP/2.0 HOST: www.jayurbain.com <line feed> Demo, also show OPTIONS, HEAD Students: Enable and run Telnet On Windows, you should be able to skip the ‘HOST: www.jayurbain.com ‘ line.

slide-29
SLIDE 29

HTTP OPTIONS

dhcp-155-92-67-24:~ jayurbain$ telnet www.jayurbain.com 80 Trying 50.63.39.1... Connected to jayurbain.com. Escape character is '^]'. OPTIONS / HTTP/2.0 host: www.jayurbain.com HTTP/1.1 200 OK Date: Wed, 19 Jul 2017 19:13:59 GMT Server: Apache Allow: OPTIONS,GET,HEAD,POST Content-Length: 0 Content-Type: text/html Connection closed by foreign host.

slide-30
SLIDE 30

HTTP HEAD

slide-31
SLIDE 31

HTTP POST

POST /path/script.cgi HTTP/1.0 From: frog@jmarshall.com User-Agent: HTTPTool/1.0 Content-Type: application/x-www-form-urlencoded Content-Length: 32 home=Cosby&favorite+flavor=flies

slide-32
SLIDE 32

Install Telnet on Windows

Telnet is a protocol that enables you to connect to remote computers and local computers

  • ver a TCP/IP network, over TCP port 23. By default, Telnet is disabled in recent Windows

environments. To enable Telnet command line utilities:

  • Click Start > Control Panel.
  • Click Programs and Features.
  • Click Turn Windows features on or off.
  • In the Windows Features dialog box, check the Telnet Client check box.
  • Click OK. The system installs the appropriate files. This will take a few seconds to a

minute. To open a Telnet session:

  • Click Start.
  • Enter cmd in the Search field in the Start menu. A command prompt is displayed.
  • Type telnet and press ENTER. The Telnet> prompt is displayed.
  • Enter: set term vt100

Skip – optional later

slide-33
SLIDE 33

JavaScript

  • Scripting language designed for creating dynamic, interactive

Web applications that link together objects and resources on both clients and servers.

  • Example usages:

– Getting your Web page to respond or react directly to user interaction with form elements and hypertext links. – Preprocessing data on the client before submission to a server. – Changing content and styles. – Ajax requests (asynchronous messages to server) – Web page interactivity with HTML5 + CSS + JavaScript. – Server-side web applications, e.g., NodeJS.

slide-34
SLIDE 34

Cookie

  • Cookie is a small piece of text stored on a user's computer by a web

browser.

  • Consists of one or more name-value pairs containing bits of information

such as user preferences.

  • A cookie can be used for:

– authenticating, – session tracking, and – remembering specific information about users.

Chrome – C:\Users\{username}\AppData\Local\Google... Data\ ~/Library/Application Support/Google/Chrome/Default/Cookies (SQLite) Firefox – ~/Library/Application Support/Firefox/Profiles/ and in this there are files called cookies.sqlite (cookies) and places.sqlite(browsing history).

slide-35
SLIDE 35

Setting A Cookie

slide-36
SLIDE 36

Cookie Expiration

  • Cookies expire, therefore they are not sent by the browser to

the server, under any of these conditions:

  • 1. At the end of the user session if the cookie is not

persistent

  • 2. An expiration date has been specified, and has passed
  • 3. The expiration date of the cookie is changed to a date in

the past

  • 4. The browser deletes the cookie by user request
slide-37
SLIDE 37

Database-driven Website Architecture

slide-38
SLIDE 38

Server-side processing

  • In server-side processing, the Web server:

– Receives the Web page request – Performs all of the processing necessary to create a dynamic Web page with data from a program or database – Sends the finished Web page to the client for display in the client’s browser – Show NLP Service: https://cis.ctsi.mcw.edu/nlp/

slide-39
SLIDE 39

Client-side processing

  • Client-side processing

– Some processing needs to be “executed” by the browser, either to form the request for the dynamic Web page or to create or display the dynamic Web page. E.g. Javascript code to validate user input, dynamic interaction, Ajax. SHOW AJAX APP – e.g., geolocation, hangman http://www.jayurbain.com/msoe/se2840/hangman- jay/hangman.html Available local only: file://localhost/Users/jayurbain/Dropbox/MSOE/www/se 2840/geolocation2016.html

slide-40
SLIDE 40

Server and Client side processing

  • Server-side processing

– PHP – ASP – ASP.NET – Perl – Java/JEE/JSP/Servlets/JSF – Python, e.g. Django – Ruby, e.g. Ruby on Rails – ColdFusion – JavaScript: NodeJS

ExpressJS – Flask

  • Client-side processing

– CSS – HTML – JavaScript – Angular – ReactJS – Bootstrap

slide-41
SLIDE 41

AJAX

Asynchronous JavaScript and XML

STOP

slide-42
SLIDE 42

Defining Ajax

  • Ajax isn’t a technology. It’s

several technologies, coming together in powerful new ways. Ajax incorporates:

– HTML and CSS; – Document Object Model; – XML and XSLT; – XMLHttpRequest; – JavaScript

Jesse James Garrett, essay in february 18, 2005 Ajax: A New Approach to Web Applications

slide-43
SLIDE 43
slide-44
SLIDE 44
slide-45
SLIDE 45

Drawbacks of AJAX

  • It breaks browser history engine (Back button).
  • No bookmark.
  • The same origin policy.
  • Ajax opens up another attack vector for malicious code that

web developers might not fully test for.

STOP

slide-46
SLIDE 46

Web Services

slide-47
SLIDE 47

Web Services

  • Web Service is a software system designed to support

machine-to-machine interaction over a network.

  • Web services are frequently just Internet Application

Programming Interfaces (API) that can be accessed over a network.

slide-48
SLIDE 48

Web Services (cont.)

  • Web Services are platform-independent and language-

independent, since they use standard XML languages.

  • Most Web Services use HTTP for transmitting messages (such

as the service request and response).

  • Style of Use

– RPC – SOAP – REST

slide-49
SLIDE 49

XML

eXtensible Markup Language

slide-50
SLIDE 50

XML

  • XML is a universally agreed markup meta-language primarily

used for information exchange.

  • The two primary building blocks of XML are elements and

attributes. – Elements are tags and have values. – Elements are structured as a tree. – Alternatively, elements may have both attributes as well as data – Attributes help you to give more meaning and describe your element more efficiently and clearly.

slide-51
SLIDE 51

XML (cont.)

<?xml version=\"1.0\" encoding=\"UTF-8\"?> <person> <id type="integer">1111</id> <last_name>Smith</last_name> <first_name>John</first_name> <address> <city>New York</city> <street>21 2nd Street</street> <postal_code type="integer">10021</postal_code> <state>NY</state> </address> </person>

slide-52
SLIDE 52

JSON

JavaScript Object Notation

slide-53
SLIDE 53

JSON

  • JSON is a lightweight computer

data interchange format.

  • JSON is based on a subset of the

JavaScript programming language.

  • It is considered to be a language-

independent data format.

  • It serves as an alternative to the

use of the XML format.

Douglas Crockford is a senior JavaScript Architect at Yahoo! He is well known for his work in introducing JavaScript Object Notation (JSON).

slide-54
SLIDE 54

JSON (cont.)

{ "firstName": "John", "lastName": "Smith", "address": { "street": "21 2nd Street", "city": "New York", "state": "NY", "postalCode": 10021 }, "phoneNumbers": [ "212 555-1234", "646 555-4567" ] }

slide-55
SLIDE 55

References

  • http://www.w3.org/standards/webarch/
  • http://www.w3.org/TR/2004/REC-webarch-20041215/
  • http://www.wikihow.com/Activate-Telnet-in-Windows-7
  • http://gdp.globus.org/gt4-tutorial/multiplehtml/ch01s02.html
  • http://www.objs.com/survey/WebArch.htm
  • http://en.wikipedia.org/wiki/World_Wide_Web
  • http://en.wikipedia.org/wiki/Web_browser
  • http://en.wikipedia.org/wiki/Web_services
  • http://en.wikipedia.org/wiki/Web_server
  • http://www.slideshare.net/warlock/intro-to-web-development
  • http://www.slideshare.net/rstein/advanced-web-development
  • http://www.slideshare.net/hblowers/intro-to-web-20-277488
  • http://www.slideshare.net/cheilmann/the-road-to-professional-web-development
  • http://en.wikipedia.org/wiki/Common_Gateway_Interface
  • http://www.edwardsamuels.com/ILLUSTRATEDSTORY/isc5.htm
  • http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol
  • http://en.wikipedia.org/wiki/HTTP_cookie
  • http://www.adaptivepath.com/ideas/newsletter/archives/111405/index.php