Development of Web Applications

Similar documents
Lecture 18. WebSocket

COMET, HTML5 WEBSOCKETS OVERVIEW OF WEB BASED SERVER PUSH TECHNOLOGIES. Comet HTML5 WebSockets. Peter R. Egli INDIGOO.COM. indigoo.com. 1/18 Rev. 2.

HTML5. HTML5 Introduction. Form Input Types. Semantic Elements. Form Attributes. Form Elements. Month Number Range Search Tel Url Time Week

Techno Expert Solutions An institute for specialized studies!

Networking & The Web. HCID 520 User Interface Software & Technology

Enabling Full-Duplex Communications in APEX

Index LICENSED PRODUCT NOT FOR RESALE

HTML5 - INTERVIEW QUESTIONS

HTML5, CSS3, JQUERY SYLLABUS

User Interaction: jquery

Networking & The Web. HCID 520 User Interface Software & Technology

Client-Server Communication

Web application Architecture

What is HTML5? The previous version of HTML came in The web has changed a lot since then.

Web Designing Course

B. V. Patel Institute of Business Management, Computer and Information Technology, UTU. B. C. A (3 rd Semester) Teaching Schedule

Controller/server communication

PHP,HTML5, CSS3, JQUERY SYLLABUS

Lecture : 3. Practical : 2. Course Credit. Tutorial : 0. Total : 5. Course Learning Outcomes

AJAX ASYNCHRONOUS JAVASCRIPT AND XML. Laura Farinetti - DAUIN

Sections and Articles

MODULE 2 HTML 5 FUNDAMENTALS. HyperText. > Douglas Engelbart ( )

ajax1.html 1/2 lectures/7/src/ ajax1.html 2/2 lectures/7/src/

Chapter 1 Getting Started with HTML 5 1. Chapter 2 Introduction to New Elements in HTML 5 21

Controller/server communication

HTML5 MOCK TEST HTML5 MOCK TEST I

RKN 2015 Application Layer Short Summary

Fundamentals of Website Development

Computer Science nd Exam Prof. Papa Tuesday, April 28, 2016, 6:00pm 7:20pm

The course also includes an overview of some of the most popular frameworks that you will most likely encounter in your real work environments.

Kaazing Gateway. Open Source HTML 5 Web Socket Server

WHAT S ALL THE FUSS ABOUT HTML5? Mark DuBois Nov. 12, 2010

src1-malan/ajax/ajax1.html ajax1.html Gets stock quote from quote1.php via Ajax, displaying result with alert().

HTML 5: Fact and Fiction Nathaniel T. Schutta

QUICK REFERENCE GUIDE

Comet and WebSocket Web Applications How to Scale Server-Side Event-Driven Scenarios

This course is designed for web developers that want to learn HTML5, CSS3, JavaScript and jquery.

Using Java with HTML5 and CSS3 (+ the whole HTML5 world: WebSockets, SVG, etc...)

Multimedia im Netz Online Multimedia Winter semester 2015/16. Tutorial 07 Minor Subject

Jim Jackson II Ian Gilman

Introduction to HTML5

Development of Web Applications

WEB DESIGNING COURSE SYLLABUS

AJAX and JSON. Day 8

LEARN HOW TO USE CA PPM REST API in 2 Minutes!

footer, header, nav, section. search. ! Better Accessibility.! Cleaner Code. ! Smarter Storage.! Better Interactions.

8/19/2018. Web Development & Design Foundations with HTML5. Learning Objectives (1 of 2) Learning Objectives (2 of 2) Helper Applications & Plug-Ins

Websocket file transfer example

AJAX. Lab. de Bases de Dados e Aplicações Web MIEIC, FEUP 2010/11. Sérgio Nunes

STRANDS AND STANDARDS

Basics of Web Technologies

Programmazione Web a.a. 2017/2018 HTML5

CS 5142 Scripting Languages

Kaazing Gateway: An Open Source

COURSE OUTLINE MOC 20480: PROGRAMMING IN HTML5 WITH JAVASCRIPT AND CSS3

quiz 1 details wed nov 17, 1pm see handout for locations covers weeks 0 through 10, emphasis on 7 onward closed book bring a , 2-sided cheat she

Static Webpage Development

AIM. 10 September

Varargs Training & Software Development Centre Private Limited, Module: HTML5, CSS3 & JavaScript

THE HITCHHIKERS GUIDE TO HTML

Web System and Technologies (Objective + Subjective)

UI Course HTML: (Html, CSS, JavaScript, JQuery, Bootstrap, AngularJS) Introduction. The World Wide Web (WWW) and history of HTML

Next... Next... Handling the past What s next - standards and browsers What s next - applications and technology

Computer Science nd Exam Prof. Papa Thursday, December 8, 2016, 6:00pm 7:20pm

10.1 Overview of Ajax

COURSE 20480B: PROGRAMMING IN HTML5 WITH JAVASCRIPT AND CSS3

Chapter 1. Introducing HTML5. Objectives: Learn what HTML5 is about. Discover what HTML5 really is

Programming in HTML5 with JavaScript and CSS3

Scalable Structured Markup. Timothy Jordan May 11th, 2011

PASS4TEST 専門 IT 認証試験問題集提供者

CSCE 120: Learning To Code

HTML HTML/XHTML HTML / XHTML HTML HTML: XHTML: (extensible HTML) Loose syntax Few syntactic rules: not enforced by HTML processors.

HTML CS 4640 Programming Languages for Web Applications

MICROSOFT EXAM QUESTIONS & ANSWERS

The realtime web: HTTP/1.1 to WebSocket, SPDY and beyond. Guillermo QCon. November 2012.

New Media Production HTML5

Lesson 12: JavaScript and AJAX

Module 6 Node.js and Socket.IO

IERG 4080 Building Scalable Internet-based Services

Table of Contents WWW. WWW history (2) WWW history (1) WWW history. Basic concepts. World Wide Web Aka The Internet. Client side.

Using CSS for page layout

GRAPHIC WEB DESIGNER PROGRAM

World Wide Web Aka The Internet. Karst Koymans. Friday, October 7, 2016

PHP & My SQL Duration-4-6 Months

Course 20480: Programming in HTML5 with JavaScript and CSS3

Webgurukul Web Development Course

Session 18. jquery - Ajax. Reference. Tutorials. jquery Methods. Session 18 jquery and Ajax 10/31/ Robert Kelly,

MICROSOFT EXAM QUESTIONS & ANSWERS

INTERNET ENGINEERING. HTTP Protocol. Sadegh Aliakbary

CORE PHP CURRICULUM. Introductory Session Web Architecture Overview of PHP Platform Origins of PHP in the open source community

CSS for Page Layout Robert K. Moniot 1

Building Web Applications with HTML5, CSS3, and Javascript: An Introduction to HTML5

Comp 426 Midterm Fall 2013

Elementary! Incorporating BlueMix, Node-RED and Watson in Domino applications

Index. C CakePHP framework, 232 Cascading Style Sheets (CSS)

Building next-gen Web Apps with WebSocket. Copyright Kaazing Corporation. All rights reserved.

Oracle - Developing Applications for the Java EE 7 Platform Ed 1 (Training On Demand)

Introduction to WEB PROGRAMMING

Master Project Software Engineering: Team-based Development WS 2010/11

Jquery Ajax Json Php Mysql Data Entry Example

Transcription:

Development of Web Applications Principles and Practice Vincent Simonet, 2015-2016 Université Pierre et Marie Curie, Master Informatique, Spécialité STL

5 Client Technologies Vincent Simonet, 2015-2016 Université Pierre et Marie Curie, Master Informatique, Spécialité STL

Today s agenda AJAX, JSONP, HTML5, WebSockets.

AJAX

AJAX Asynchronous JavaScript and XML With AJAX, a JavaScript script can send data to, and retrieve data from, a server asynchronously (in the background) without interfering with the display and behavior of the existing page. Despite the name, the use of XML is not required. In fact, JSON is much more popular.

AJAX call example var xhr = new XMLHttpRequest(); xhr.open('get', 'http://example/method'); xhr.onreadystatechange = function() { // Ready state 4 means the request is done if (xhr.readystate === 4) { if (xhr.status === 200) { alert('success: ' + xhr.responsetext); } else { alert('error: ' + xhr.status); } } } xhr.send(null);

AJAX: XML or JSON response XML response: xhr.responsetype = "document"; xhr.responsexml.documentelement JSON response: xhr.responsetype = "json"; eval(xhr.responsetext) (if you trust the response source!).

Same origin policy AJAX requests can be made only to URLs of the same domain (host and port) as the page. AJAX is hence useful for communication with the server of a web application, but not for doing calls to a third-party API. For remote API calls, several workarounds are used: JSONP (by far the most popular), Using the application server as a proxy (costly), iframes / using the URL to communicate (tricky), Messages (the clean way, in HTML5).

W3C Specification Level 1 (1999) Level 2 (2008) progress events, support for cross-site requests, handling of byte streams http://www.w3.org/tr/xmlhttprequest/ http://www.w3.org/tr/xmlhttprequest2/

JSONP

JSONP JSON with Padding An alternative to AJAX, for requesting data from a server in a different domain. How it works? The client script generates the request by adding a <script> tag to the page: <script type="application/javascript" src="http://directory/?id=42"> The server returns a JavaScript containing a JSON value, wrapped into a function call (the padding): callback({"id": 42, "name": "Vincent Simonet"});

JSONP in practice The name of the padding is usually passed as an argument in the request: <script type="application/javascript" src="...?id=42&jsonp=mycallback"> mycallback({"id": 42, "name": "Vincent Simonet"}); JavaScript frameworks provide helper functions for making this transparent. E.g. in jquery: $.ajax({url : 'http://.../?id=42', datatype : 'jsonp', jsonp : 'jsonp', success : function(data){} });

JSONP limitations Only GET (POST is doable, but tricky), No access to HTTP headers (in request and response), including cookies.

WebSockets

The problem In HTTP and AJAX, all exchanges are initiated by client requests. In some applications, it is useful to have the server pushing information to the client. E.g.: Notifications in a news website, Messages in a chat system, etc.

Workaround solutions The client can make periodic requests to the server, The client can make a request to the server, which will answer with an "infinite" response. Known as Comet. Several implementations: Streaming (using iframe or special XmlHttpRequest), Long polling (using XmlHttpRequest or script tags).

The HTML5 solution: WebSockets WebSocket is is a protocol providing full-duplex communications channels over a single TCP connection. Enables a stream of messages. Its only relationship to HTTP are: its handshake is interpreted by HTTP servers as an Upgrade request, it is using port 80 as default port.

WebSocket protocol handshake Request: GET /mychat HTTP/1.1 Host: server.example.com Upgrade: websocket Connection: Upgrade Sec-WebSocket-Key: x3jjhmbdl1ezlkh9gbhxdw== Sec-WebSocket-Protocol: chat Sec-WebSocket-Version: 13 Origin: http://example.com Response: HTTP/1.1 101 Switching Protocols Upgrade: websocket Connection: Upgrade Sec-WebSocket-Accept: HSmrc0sMlYUkAGmm5OPpG2HaGWk= Sec-WebSocket-Protocol: chat

Client-side JavaScript API var connection = new WebSocket('ws://.../echo', ['soap', 'xmpp']); connection.onopen = function () { connection.send('ping'); }; connection.onerror = function (error) { console.log('websocket Error ' + error); }; connection.onmessage = function (e) { console.log('server: ' + e.data); };

Server-side implementations Java: Jetty Node.js: ws, WebSocket-Node Python: pywebsocket

HTML5

What is HTML5? The 5th version of the HTML language, subsuming HTML 4.01 and XHTML 1.1 New/extended markup, and a galaxy of APIs.

Specification status

Implementation status Source: html5test.com

Main HTML5 features Semantic tags, Canvas, Video, Geo-localisation, Local storage, Offline, Improved forms, Microdata, History manipulation.

Tags in HTML5 Semantic replacements of <div> or <span>: <nav> <header> <footer> <section> <hgroup> <article> <aside> <time> <mark> Replacements of <object>: <audio> <video> Removal of some style tags: <font> <center> <strike> <tt> (non-exhaustive list)

Canvas HTML: <canvas id="c" width="500" height="375"></canvas> JavaScript: var c_canvas = document.getelementbyid ("c"); var context = c_canvas.getcontext("2d"); for (var x = 0.5; x < 500; x += 10) { context.moveto(x, 0); context.lineto(x, 375); }

Geo-localisation navigator.geolocation.getcurrentposition( handle_success, handle_error, options); function handle_success(position) { var latitude = position.coords.latitude; var longitude = position.coords.longitude; // let's do something interesting! } function handle_error(error) { } alert(error.code + ': ' + error.message);

Geo-localisation

Improved forms New input types: color, date, datetime, datetimelocal, email, month, number, range, search, tel, time, url, week <input type="color" name="favcolor"> <input type="number" name="quantity" min="1" max="5"> New input attributes: autocomplete, autofocus, multiple, min, max, pattern, required, etc. New elements: <datalist> <keygen> <output> Use them!

Microdata <article itemscope itemtype= "http://data-vocabulary.org/organization"> <h1 itemprop="name">google, Inc.</h1> <p itemprop="address" itemscope itemtype="http://data-vocabulary.org/address"> <span itemprop="street-address"> 1600 Amphitheatre Parkway</span><br> <span itemprop="locality">mountain View</span>, <span itemprop="region">ca</span> <span itemprop="postal-code">94043</span><br> <span itemprop="country-name">usa</span> </p> <p itemprop="tel">650-253-0000</p> </article>

History manipulation window.history.pushstate( "object or string", "Title", "/new-url"); window.history.replacestate( "object or string", "Title", "/new-url"); window.addeventlistener("popstate", function(e) { swapphoto(location.pathname); });

http://diveintohtml5.info/