Carnegie Mellon Heinz College

Slides:



Advertisements
Similar presentations
IS 360 Course Introduction. Slide 2 What you will Learn (1) The role of Web servers and clients How to create HTML, XHTML, and HTML 5 pages suitable for.
Advertisements

Ajax (Asynchronous JavaScript and XML). AJAX  Enable asynchronous communication between a web client and a server.  A client is not blocked when an.
JavaScript & jQuery the missing manual Chapter 11
Chapter 17 - Deploying Java Applications on the Web1 Chapter 17 Deploying Java Applications on the Web.
1 rfXcel Confidential Copyright 2007 Web Technology JavaScript 12/10/07.
HTML5 Communication. The Setup Somewhere on the web, a server makes a ”service” available, that we wish to use in a web application The service may offer.
1 Geospatial and Business Intelligence Jean-Sébastien Turcotte Executive VP San Francisco - April 2007 Streamlining web mapping applications.
1 MSCS 237 Overview of web technologies (A specific type of distributed systems)
AJAX Compiled from “AJAX Programming” [Sang Shin] (Asynchronous JavaScript and XML)
Asynchronous Javascript And XML AJAX : an introduction UFCEUS-20-2 : Web Programming.
BASIC NETWORK PROTOCOLS AND THEIR FUNCTIONS Created by: Ghadeer H. Abosaeed June 23,2012.
IS-907 Java EE World Wide Web - Overview. World Wide Web - History Tim Berners-Lee, CERN, 1990 Enable researchers to share information: Remote Access.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
 AJAX – Asynchronous JavaScript and XML  Ajax is used to develop fast dynamic web applications  Allows web pages to be updated asynchronously by transferring.
SE-2840 Dr. Mark L. Hornick 1 Introduction to Ajax Asynchronous Javascript And XML.
AJAX and REST. Slide 2 What is AJAX? It’s an acronym for Asynchronous JavaScript and XML Although requests need not be asynchronous It’s not really a.
AJAX Use Cases for WSRP Subbu Allamaraju BEA Systems Inc WSRP F2F Meeting, May 2006.
AJAX – Asynchronous JavaScript And XML By Kranthi Kiran Nuthi CIS 764 Kansas State University.
Web Technology (NCS-504) Prepared By Mr. Abhishek Kesharwani Assistant Professor,UCER Naini,Allahabad.
AJAX CS456 Fall Examples Where is AJAX used? Why do we care?
JavaScript, Sixth Edition Chapter 11 Updating Web Pages with Ajax.
NCCUCS 軟體工程概論 Lecture 5: Ajax, Mashups April 29, 2014.
National College of Science & Information Technology.
4.01 How Web Pages Work.
Ethernet, WiFi & Protocols
4.01 How Web Pages Work.
CS299: Web Programming and Design Instructor: Dr. Fang (Daisy) Tang
4.01 How Web Pages Work.
Internet Technologies
JavaScript and Ajax (Ajax Tutorial)
IoT Integration Patterns, REST, and CoAP
CSE 154 Lecture 11: AJAx.
Not a Language but a series of techniques
Data Virtualization Tutorial… CORS and CIS
Web Languages What Is a Web Page?
AJAX and REST.
Lecture 1: Introduction
Subbu Allamaraju BEA Systems Inc
XMLHttp Object.
AJAX.
Professional Web Designing For Absolute Beginners
AJAX.
Addresses on the Web.
Prepared for Md. Zakir Hossain Lecturer, CSE, DUET Prepared by Miton Chandra Datta
Web Of Things REST WoT Integration Patterns CoAP
Packet Sniffing.
CSE 154 Lecture 11: AJAx.
Web Languages What Is a Web Page?
Session V HTML5 APIs - AJAX & JSON
Topic 5: Communication and the Internet
CSE 154 Lecture 22: AJAX.
AJAX Robin Burke ECT 360.
HTML Level II (CyberAdvantage)
HTML5 AJAX & JSON APIs
Introduction to HTML5 and WebSockets.
TCP/IP Protocol Suite: Review
JavaScript & jQuery AJAX.
Secure Web Programming
MIS JavaScript and API Workshop (Part 3)
Chengyu Sun California State University, Los Angeles
Lecture 12: The Fetch Api and AJAx
AJAX CS-422 Dick Steflik.
WEB SERVICES From Chapter 19, Distributed Systems
Lecture 12: The Fetch Api and AJAx
Intro to Ajax Fred Stluka Jan 25, 2006.
DR. JOHN ABRAHAM PROFESSOR UTPA
4.01 How Web Pages Work.
Ajax and JSON Jeremy Shafer Department of MIS Fox School of Business
Lecture 1: Introduction to Course Structure
AJAX By Prof. B.A.Khivsara
Presentation transcript:

Carnegie Mellon Heinz College 95-733 Internet of Things Carnegie Mellon Heinz College

Four Interaction Styles Four common client server interaction patterns using HTTP. Some details on the last three styles. Note: You should be working on Project 1. And still prepare for next week’s quiz on “Enabling the Internet of Things”. Carnegie Mellon Heinz College

The Internet Protocol Suite HTTP, Websockets, DNS, XMPP, MQTT, CoAp Application layer TLS, SSL Application Layer (Encryption) TCP, UDP Transport Layer IP(V4, V6), 6LowPAN Internet Layer Ethernet, 802.11 WiFi, 802.15.4 (used by Zigbee, Thread) Link Layer Important principles: Layering, modularity, separation of concerns Each layer focuses on a particular set of concerns and abstracts these concerns from the layer above. In this course, we will mainly study the application layer. 3 Carnegie Mellon Heinz College Carnegie Mellon Heinz College

Types of Physical Communication Channels Communications Channels (two types) - Wireline Optical (fiber) using light Electrical using voltages and current Twisted pair Coaxial cable Waveguide - Wireless Optical – e.g. infrared, electromagnetic Radio – most common (from NFC to satellite) Acoustic – e.g. underwater communications Each of these is a major topic. Carnegie Mellon Heinz College

Four Styles of HTTP Interaction Style(1) Client (browser) get request Server http/tcp/ip response may include html, css, javascript html may includes hyperlinks The response or user interaction may cause code to execute within the browser The request may cause code to execute on the server Carnegie Mellon Heinz College

Four Styles of HTTP Interaction Style(2) Client (browser) Server API Page is rendered. New calls made by Javascript Data provided as needed Asynchronous (non-blocking) javascript and xml (AJAX) No need for a full page refresh Same origin policy enforced by browser Carnegie Mellon Heinz College

Four Styles of HTTP Interaction Style(3) Client (browser) Server Response includes code to cause additional requests to others. E.g., an <img> tag is returned. This causes an HTTP Get to occur elsewhere. Javascript object notation with padding (jsonp) is a popular hack. No longer restricted to the the same origin. Upon return, a callback is executed. Newer systems use CORS - Cross Origin Resource Sharing. The third party server has a white list of acceptable domains. Carnegie Mellon Heinz College

Four Styles of HTTP Interaction Style(4) Client (browser) Server Response includes Websocket code in javascript peer Bidirectional Communication over TCP/IP peer Once the socket is established, the server may initiate the interaction. Uses: Web - collaboration apps without polling IoT - very fast binary or text Carnegie Mellon Heinz College

Carnegie Mellon Heinz College AJAX (Style 2) The traditional web employed thin clients. With AJAX, downloaded code interacts with the server asynchronously. The client does not block. This makes for a more responsive user experience. Single page applications are possible. This is widely used. Carnegie Mellon Heinz College

Since we are developing in Java we need to know… A servlet is Java code that runs on the server when an HTTP request arrives. A Java Server Page (JSP) is XHTML+ Java and is compiled to a servlet. JavaScript is not Java and runs in the browser. To experiment with Javascript: In Firefox tools/web developer/web console/scratchpad Carnegie Mellon Heinz College

Carnegie Mellon Heinz College Typical AJAX interaction pattern This is a UML sequence diagram. This shows a typical AJAX round trip. A solid arrowhead represents a synchronous call. A stick arrowhead represents an asynchronous signal. Carnegie Mellon Heinz College

Javascript Example 1 (W3C) Some simple JavaScript code to do something with data from an XML document or JSON string fetched over the network: function test(data) { // taking care of data } Carnegie Mellon Heinz College

Carnegie Mellon Heinz College function handler() { if(this.readyState == 4 && this.status == 200) { // so far so good if(this.responseXML != null && this.responseXML.getElementById('test').firstChild.data) // success! test(this.responseXML.getElementById('test').firstChild.data); else test(null); } else if (this.readyState == 4 && this.status != 200) { // fetched the wrong page or network error... } var client = new XMLHttpRequest(); client.onreadystatechange = handler; client.open("GET", "test.xml"); client.send(); Carnegie Mellon Heinz College

Javascript Example 2 (W3C) If you just want to ping the server with a message you could do something like: function ping(message) { var client = new XMLHttpRequest(); client.open("POST", "/ping"); client.send(message); } We are not establishing a callback handler. We are not interested in a response. Carnegie Mellon Heinz College

Javascript Example 3 (W3C) Or, if you want to check the status of a document on the server, you can make a head request. function fetchStatus(address) { var client = new XMLHttpRequest(); client.onreadystatechange = function() { if(this.readyState == 4) returnStatus(this.status); } client.open("HEAD", address); client.send(); Carnegie Mellon Heinz College

Carnegie Mellon Heinz College State and State Change The state of the object. The readyState attribute must be one of the following values: 0 Uninitialized The initial value. 1 Open The open() method has been successfully called. 2 Sent The user agent successfully acknowledged the request. 3 Receiving Immediately before receiving the message body (if any). All HTTP headers have been received. 4 Loaded The data transfer has been completed. When readyState changes value a readystatechange event is to be dispatched on the XMLHttpRequest object. Carnegie Mellon Heinz College

AJAX Typical Interaction post JavaScript function XML XMLHTTPRequest handler - Executed on state change. - this.responseXML points to the root of the XML write HTML to HTML DOM HTML Button Carnegie Mellon Heinz College