SlideShare uma empresa Scribd logo
1 de 61
Introduction to RIA and AJAX Created by - Schubert [email_address]
Agenda ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Agenda – cont’d
RIA – Rich Internet Applications
Introduction -  i ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Introduction –  ii Thick Client – Thin Client Server Client Data Data Data Data Business Logic Presentation Logic Presentation Logic Business Logic Business Logic Presentation Logic UI Engine Business Logic Presentation Logic HTML
Introduction -  iii The need for smart clients
Introduction -  iv RIA Richness Communication Application Bringing the Desktop to the Web ! Connected / Alive Interactive Responsive Traditional web  Pervasiveness Online / Offline mode Event’s, notification Security Accessibility A RIA
Web 2.0 -  i ,[object Object],[object Object],mp3.com Britannica Online personal websites page views publishing content management systems stickiness WEB 1.0 Napster Wikipedia blogging cost per click participation wikis syndication WEB 2.0
Web 2.0 -  ii By products
RIA Frameworks and toolkits ,[object Object],[object Object],[object Object],[object Object],[object Object]
Web Orientation
HTML – DOM HTML - Are HTML document structures validated ? -  <!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01//EN&quot; &quot;http://www.w3.org/TR/html4/strict.dtd&quot;> - What is XHTML ? - HTML 5 and XHTML 5 DOM  
CSS CSS Color – Visibility – Positioning - Backgrounds
HTTP -  i OSI (Open Systems Interconnection) – Reference model Application Presentation Session Transport Network Datalink Physical HTTP Headers Methods Status codes
HTTP -  ii HTTP headers Request Headers Response Headers ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
HTTP -  iii HTTP methods Get - Conditional GET (if headers such as  if-modified-since , etc are present.) - Partial GET (if headers include  ranges , avoids data transmission already held by the client) POST - Provide a block of data for processing HEAD - Identical to GET except that the server MUST NOT return a message-body in the response.  (used for testing hypertext links for validity, accessibility, and recent modification.) PUT / DELETE / TRACE / CONNECT / OPTIONS
HTTP -  iv HTTP status codes Informational Success Re - Direction Client Error Server Error 1xx 2xx 3xx 4xx 5xx 100 Continue 200 OK 202 Accepted 301 Moved Permanently 304 Not Modified 400 Bad Request 403 Forbidden 404 Not Found 500 Internal Server Error 502 Bad Gateway 503 Service Unavailable
XML / JSON -  i ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
XML / JSON -  ii {&quot;menu&quot;: { &quot;id&quot;: &quot;file&quot;, &quot;value&quot;: &quot;File&quot;, &quot;popup&quot;: { &quot;menuitem&quot;: [ {&quot;value&quot;: &quot;New&quot;, &quot;onclick&quot;: &quot;CreateNewDoc()&quot;}, {&quot;value&quot;: &quot;Open&quot;, &quot;onclick&quot;: &quot;OpenDoc()&quot;}, {&quot;value&quot;: &quot;Close&quot;, &quot;onclick&quot;: &quot;CloseDoc()&quot;} ] } }} <menu id=&quot;file&quot; value=&quot;File&quot;> <popup> <menuitem value=&quot;New&quot; onclick=&quot;CreateNewDoc()&quot; /> <menuitem value=&quot;Open&quot; onclick=&quot;OpenDoc()&quot; /> <menuitem value=&quot;Close&quot; onclick=&quot;CloseDoc()&quot; /> </popup> </menu> JSON v/s XML
AJAX
Introduction AJAX (Asynchronous JavaScript and XML) Ajax can be defined as a group of interrelated web development techniques used to create interactive web applications or rich Internet applications. AJAX CSS / XHTML DOM XML / XSLT XHR Presentation semantics Dynamic display and data interaction Interchange and manipulation Object for communication
Introduction -  i AJAX interactions – classical web model
Introduction -  i AJAX interactions – the ajax model
The XMLHTTPRequest object -  i The XMLHttpRequest Object  specification  defines an API that provides scripted client functionality for transferring data between a client and a server. The XMLHttpRequest object implements an interface exposed by a scripting engine that allows scripts to perform HTTP client functionality, such as submitting form data or loading data from a server. Supports any text based format, including XML It can be used to make requests over both HTTP and HTTPS Supports all activity involved with HTTP requests or responses for the defined HTTP methods .
The XMLHTTPRequest object -  ii Dependencies ,[object Object],[object Object],[object Object]
The XMLHTTPRequest object -  iii XHR Object state, events and exceptions XHR Object State UNSENT  (Constant value – 0) OPEN  (Constant value – 1) SENT  (Constant value – 2) LOADING  (Constant value – 3) DONE  (Constant value – 4) XHR Object Exceptions    XMLHttpRequestException NETWORK_ERR ABORT_ERR XHR Event    readystatechange
The XMLHTTPRequest object -  iv XHR Object state -  elaborated Unsent When constructed, the XMLHttpRequest object must be in the UNSENT state. This state is represented by the UNSENT constant, whose value is 0. Open The OPEN state is the state of the object when the open() method has been successfully invoked. During this state request headers can be set using setRequestHeader() and the request can be made using send(). Sent The SENT state is the state of the object when the user agent successfully acknowledged the request. Loading The LOADING state is the state of the object when all HTTP headers have been received. The object typically remains in this state until the complete message body (if any) has been received. Done The DONE state is the state of the object when either the data transfer has been completed or something went wrong during the transfer.
The XMLHTTPRequest object -  v XHR methods open(<method>, <url>) This prepares the XHR object for a call to the server. If you are passing parameters with via GET, you can append them to the URL here. send(<body>) This method actually sends the request to the server.  The body parameter can be used to pass any POST parameters that you would like.  You can format your POST parameters just like a GET query-string setRequestHeader(<header>, <value>) This method allows you to set the specified header with the given value. (e.g. content-type) getAllResponseHeaders() Returns all the response headers as a key / value pair. getResponseHeader(<header>) Returns the specific header requested. abort() Aborts the operation
The XMLHTTPRequest object -  vi XHR properties onreadystatechange This property sets the method to be called on every state change.  This is usually your event handler for the asynchronous callback readyState This property defines the state of the XHR.  Possible values include: 0      Uninitated  (open() has not been called) 1      Loading  (send() has not been called)  2      Loaded  (send() has been called, and headers and status are available.)   3      Interactive  (Downloading; responseText holds partial data) 4      Complete  (Operation is complete) When sending the XHR, you will check to see if the readyState is 0 or 4, and in your asynchronous callback handler, you will check to see if the readyState is 4. responseText This returns the response from the server as a string. (Typically text, JSON)
The XMLHTTPRequest object -  vii XHR properties responseXML This returns the response from the server as an XML document.  This is the way to go if you need to return multiple values from your AJAX request.  status This returns the HTTP status code from the server such as 200 for OK or 404 for not found. status This returns a string representation of the HTTP status code such as OK for 200 and Not Found for 404
The XMLHTTPRequest object -  viii XMLHttpRequest Level 2 ,[object Object],[object Object],[object Object],[object Object]
AJAX code – decoded -  i var xmlHttp = GetXmlHttpObject(); if (xmlHttp==null) { alert (&quot;Your browser does not support AJAX!&quot;); return; } var url = “validate.jsp&quot;; url = url + &quot;?id=“ + str; xmlHttp.onreadystatechange = stateChanged; xmlHttp.open(&quot;GET&quot;,url); xmlHttp.send(null);  Function to get the XHR object event handler for the asynchronous callback prepare the XHR object for a call to the server Send the request to the server
AJAX code – decoded -  ii function stateChanged() {  if (xmlHttp.readyState == 4) {  if (req.status == 200) { document.getElementById(“validHint&quot;).innerHTML = xmlHttp.responseText; } } } Event handler code
AJAX code – decoded -  iii function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject(&quot;Msxml2.XMLHTTP&quot;); } catch (e) { xmlHttp=new ActiveXObject(&quot;Microsoft.XMLHTTP&quot;); } } return xmlHttp; } Getting the XHR object Pre 5.5 versions of IE
AJAX code – decoded -  iv Code overview
AJAX code – decoded -  v UML overview
DOM manipulation concepts var tr = document.createElement('TR'); var td = document.createElement('TD'); tr.appendChild(td); tr.style.backgroundColor = <some color> tr.childNodes tr.firstChild tr.lastChild var parent = td.parentNode; tr.removeChild(td); var img = document.createElement('IMG'); img.setAttribute('src', 'delete.gif'); img.onclick = function() {   // function code } Creating elements Adding child elements Setting element properties Referencing child nodes Accessing the parent node Removing parent nodes Assigning behavior to dynamically created elements
Basic high-level ajax architecture
Design Patterns
Design Patterns ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Frameworks and Toolkits
Frameworks and Toolkits -  i Google Web Toolkit
Frameworks and Toolkits -  ii YUI – Yahoo User Interface
Frameworks and Toolkits -  iii jMaki
Frameworks and Toolkits -  iv DEMO Google Web Toolkit (GWT) Yahoo User Interface (YUI) extJS
Ajax – Security and Performance related aspects
Security issues -  i JavaScript Hijacking JavaScript Hijacking allows an unauthorized attacker to read confidential data from a vulnerable application using a technique similar to the one commonly used to create mash-ups. Traditional Web applications are not vulnerable to JavaScript Hijacking because they do not use JavaScript as a  data transport mechanism. ,[object Object],[object Object],[object Object],[object Object]
Security issues -  ii Precautions against JavaScript Hijacking ,[object Object],[object Object],The best way to defend against JavaScript Hijacking is to do adopt both defensive tactics.
Security issues -  iii Declining Malicious requests ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Security issues -  iv Preventing direct execution of the Response In order to make it impossible for a malicious site to execute a response that includes JavaScript, the legitimate client application can take advantage of the fact that it is allowed to modify the data it receives before executing it, while a malicious application can only execute it using a <script> tag. When the server serializes an object, it should include a prefix (and potentially a suffix) that makes it impossible to execute the JavaScript using a <script> tag. The legitimate client application can remove this extraneous data before running the JavaScript. Example 1: Prefixing text like  while(1) req.open(&quot;GET&quot;, &quot;/object.json&quot;); req.onreadystatechange = function () { if (req.readyState == 4) { var txt = req.responseText; if (txt.substr(0,9) == &quot;while(1);&quot;) { txt = txt.substring(10); } object = eval(&quot;(&quot; + txt + &quot;)&quot;); req = null; } }; Unless the client removes this prefix, evaluating the message will send the JavaScript interpreter into an infinite loop.
Security issues -  v Preventing direct execution of the Response Example 2: T he server can include comment characters around the JavaScript that have to be removed before the JavaScript is sent to eval() /* [{&quot;fname&quot;:“Larry&quot;, &quot;lname&quot;:“Ellison&quot;, &quot;phone&quot;:&quot;6502135600&quot;, &quot;purchases&quot;:60000.00, &quot;email&quot;:“larry@oracle.com&quot; } ] */ Unless the client removes these comment characters, the JS code will not be able to be evaluated.
Performance issues -  i ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Performance issues -  ii What would we like to monitor ? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Ajax – Advantages & Disadvantages
Advantages ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Disadvantages ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Code Samples
Requirements ,[object Object],[object Object],[object Object],[object Object]
Code sample for a Login request <jsp> login.jsp Accept user credentials Login-ajax.js <jsp> validatelogin.jsp JDBC Database 1 2 3 4 5 6 Success / Failure 7 Behind the Scenes – using fire bug
Disclaimer ,[object Object],[object Object],[object Object]

Mais conteúdo relacionado

Mais procurados

Jumps in Assembly Language.
Jumps in Assembly Language.Jumps in Assembly Language.
Jumps in Assembly Language.NA000000
 
Internet architecture protocol
Internet architecture protocolInternet architecture protocol
Internet architecture protocolGLIM Digital
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to phpAnjan Banda
 
Introduction to web technology
Introduction to web technologyIntroduction to web technology
Introduction to web technologyVARSHAKUMARI49
 
Queue AS an ADT (Abstract Data Type)
Queue AS an ADT (Abstract Data Type)Queue AS an ADT (Abstract Data Type)
Queue AS an ADT (Abstract Data Type)Self-Employed
 
Beginners PHP Tutorial
Beginners PHP TutorialBeginners PHP Tutorial
Beginners PHP Tutorialalexjones89
 
Unicast multicast & broadcast
Unicast multicast & broadcastUnicast multicast & broadcast
Unicast multicast & broadcastNetProtocol Xpert
 
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...Linked List, Types of Linked LIst, Various Operations, Applications of Linked...
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...Balwant Gorad
 

Mais procurados (20)

TCP/ IP
TCP/ IP TCP/ IP
TCP/ IP
 
PHP POWERPOINT SLIDES
PHP POWERPOINT SLIDESPHP POWERPOINT SLIDES
PHP POWERPOINT SLIDES
 
Telnet
TelnetTelnet
Telnet
 
OSI Model
OSI ModelOSI Model
OSI Model
 
Sessions in php
Sessions in php Sessions in php
Sessions in php
 
Jumps in Assembly Language.
Jumps in Assembly Language.Jumps in Assembly Language.
Jumps in Assembly Language.
 
OSI 7 Layer Model
OSI 7 Layer ModelOSI 7 Layer Model
OSI 7 Layer Model
 
PHP FUNCTIONS
PHP FUNCTIONSPHP FUNCTIONS
PHP FUNCTIONS
 
Internet architecture protocol
Internet architecture protocolInternet architecture protocol
Internet architecture protocol
 
Finite Automata
Finite AutomataFinite Automata
Finite Automata
 
Rarp
RarpRarp
Rarp
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
Introduction to web technology
Introduction to web technologyIntroduction to web technology
Introduction to web technology
 
Osi model
Osi modelOsi model
Osi model
 
Queue AS an ADT (Abstract Data Type)
Queue AS an ADT (Abstract Data Type)Queue AS an ADT (Abstract Data Type)
Queue AS an ADT (Abstract Data Type)
 
Beginners PHP Tutorial
Beginners PHP TutorialBeginners PHP Tutorial
Beginners PHP Tutorial
 
Php and MySQL
Php and MySQLPhp and MySQL
Php and MySQL
 
Unicast multicast & broadcast
Unicast multicast & broadcastUnicast multicast & broadcast
Unicast multicast & broadcast
 
Telnet ppt
Telnet pptTelnet ppt
Telnet ppt
 
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...Linked List, Types of Linked LIst, Various Operations, Applications of Linked...
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...
 

Destaque

Rich Internet Applications (RIA)
Rich Internet Applications (RIA)Rich Internet Applications (RIA)
Rich Internet Applications (RIA)guest3214e8
 
Basics of Rich Internet Applications
Basics of Rich Internet ApplicationsBasics of Rich Internet Applications
Basics of Rich Internet ApplicationsSubramanyan Murali
 
Xay Dung Thuong Hieu
Xay Dung Thuong HieuXay Dung Thuong Hieu
Xay Dung Thuong Hieuhaanh147
 
Donkr.COM Social community presentation
Donkr.COM Social community presentationDonkr.COM Social community presentation
Donkr.COM Social community presentationIvo Capins
 
Social mediamarketing industry report 2012
Social mediamarketing industry report 2012Social mediamarketing industry report 2012
Social mediamarketing industry report 2012Vasco Marques
 
Creative Commons. Jak produkować i dystrybuować treści w czasach mediów społ...
Creative Commons.  Jak produkować i dystrybuować treści w czasach mediów społ...Creative Commons.  Jak produkować i dystrybuować treści w czasach mediów społ...
Creative Commons. Jak produkować i dystrybuować treści w czasach mediów społ...Alek Tarkowski
 
In Focus May June 2008 Final
In Focus May June 2008 FinalIn Focus May June 2008 Final
In Focus May June 2008 FinalMarshall Oseas
 
Sun Software
Sun SoftwareSun Software
Sun Softwaremnalls
 
How Learning Management Solutions Meet Compliance & Regulatory Requirements
How Learning Management Solutions Meet Compliance & Regulatory RequirementsHow Learning Management Solutions Meet Compliance & Regulatory Requirements
How Learning Management Solutions Meet Compliance & Regulatory Requirementsmarcblumenthal
 
Bucaille
BucailleBucaille
BucailleNau Al
 
Flex Data Access
Flex Data AccessFlex Data Access
Flex Data Accesssergiy
 
Scratch
ScratchScratch
Scratchjepcke
 
SQALE Software Quality Assessment based on Lifecycle Expectations
SQALE Software Quality Assessment based on Lifecycle ExpectationsSQALE Software Quality Assessment based on Lifecycle Expectations
SQALE Software Quality Assessment based on Lifecycle ExpectationsGlaucio Scheibel
 
Work of the Year
Work of the YearWork of the Year
Work of the Yearguestfdb62f
 
Marketing pessoal e neworking
Marketing pessoal e neworkingMarketing pessoal e neworking
Marketing pessoal e neworkingVasco Marques
 

Destaque (20)

Rich Internet Applications (RIA)
Rich Internet Applications (RIA)Rich Internet Applications (RIA)
Rich Internet Applications (RIA)
 
Basics of Rich Internet Applications
Basics of Rich Internet ApplicationsBasics of Rich Internet Applications
Basics of Rich Internet Applications
 
Mashup ppt
Mashup pptMashup ppt
Mashup ppt
 
Xay Dung Thuong Hieu
Xay Dung Thuong HieuXay Dung Thuong Hieu
Xay Dung Thuong Hieu
 
Reboot 2020
Reboot 2020Reboot 2020
Reboot 2020
 
Donkr.COM Social community presentation
Donkr.COM Social community presentationDonkr.COM Social community presentation
Donkr.COM Social community presentation
 
Social mediamarketing industry report 2012
Social mediamarketing industry report 2012Social mediamarketing industry report 2012
Social mediamarketing industry report 2012
 
Creative Commons. Jak produkować i dystrybuować treści w czasach mediów społ...
Creative Commons.  Jak produkować i dystrybuować treści w czasach mediów społ...Creative Commons.  Jak produkować i dystrybuować treści w czasach mediów społ...
Creative Commons. Jak produkować i dystrybuować treści w czasach mediów społ...
 
In Focus May June 2008 Final
In Focus May June 2008 FinalIn Focus May June 2008 Final
In Focus May June 2008 Final
 
Sun Software
Sun SoftwareSun Software
Sun Software
 
How I Lern English
How I Lern EnglishHow I Lern English
How I Lern English
 
香港六合彩
香港六合彩香港六合彩
香港六合彩
 
How Learning Management Solutions Meet Compliance & Regulatory Requirements
How Learning Management Solutions Meet Compliance & Regulatory RequirementsHow Learning Management Solutions Meet Compliance & Regulatory Requirements
How Learning Management Solutions Meet Compliance & Regulatory Requirements
 
Presentation2
Presentation2Presentation2
Presentation2
 
Bucaille
BucailleBucaille
Bucaille
 
Flex Data Access
Flex Data AccessFlex Data Access
Flex Data Access
 
Scratch
ScratchScratch
Scratch
 
SQALE Software Quality Assessment based on Lifecycle Expectations
SQALE Software Quality Assessment based on Lifecycle ExpectationsSQALE Software Quality Assessment based on Lifecycle Expectations
SQALE Software Quality Assessment based on Lifecycle Expectations
 
Work of the Year
Work of the YearWork of the Year
Work of the Year
 
Marketing pessoal e neworking
Marketing pessoal e neworkingMarketing pessoal e neworking
Marketing pessoal e neworking
 

Semelhante a RIA and Ajax

01. http basics v27
01. http basics v2701. http basics v27
01. http basics v27Eoin Keary
 
Unit-5.pptx
Unit-5.pptxUnit-5.pptx
Unit-5.pptxitzkuu01
 
AJAX Workshop Notes
AJAX Workshop NotesAJAX Workshop Notes
AJAX Workshop NotesPamela Fox
 
Introduction to Web Architecture
Introduction to Web ArchitectureIntroduction to Web Architecture
Introduction to Web ArchitectureChamnap Chhorn
 
jkljklj
jkljkljjkljklj
jkljkljhoefo
 
jQuery : Talk to server with Ajax
jQuery : Talk to server with AjaxjQuery : Talk to server with Ajax
jQuery : Talk to server with AjaxWildan Maulana
 
Scalable network applications, event-driven - Node JS
Scalable network applications, event-driven - Node JSScalable network applications, event-driven - Node JS
Scalable network applications, event-driven - Node JSCosmin Mereuta
 
REST & RESTful Web Service
REST & RESTful Web ServiceREST & RESTful Web Service
REST & RESTful Web ServiceHoan Vu Tran
 
ASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiTiago Knoch
 
RESTful SOA - 中科院暑期讲座
RESTful SOA - 中科院暑期讲座RESTful SOA - 中科院暑期讲座
RESTful SOA - 中科院暑期讲座Li Yi
 
Introduction to Ajax programming
Introduction to Ajax programmingIntroduction to Ajax programming
Introduction to Ajax programmingFulvio Corno
 
Restful web services with java
Restful web services with javaRestful web services with java
Restful web services with javaVinay Gopinath
 
Rest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.jsRest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.jsCarol McDonald
 

Semelhante a RIA and Ajax (20)

01. http basics v27
01. http basics v2701. http basics v27
01. http basics v27
 
Unit-5.pptx
Unit-5.pptxUnit-5.pptx
Unit-5.pptx
 
AJAX Workshop Notes
AJAX Workshop NotesAJAX Workshop Notes
AJAX Workshop Notes
 
Introduction to Web Architecture
Introduction to Web ArchitectureIntroduction to Web Architecture
Introduction to Web Architecture
 
AJAX Transport Layer
AJAX Transport LayerAJAX Transport Layer
AJAX Transport Layer
 
jkljklj
jkljkljjkljklj
jkljklj
 
jQuery : Talk to server with Ajax
jQuery : Talk to server with AjaxjQuery : Talk to server with Ajax
jQuery : Talk to server with Ajax
 
Ajax
AjaxAjax
Ajax
 
AJAX
AJAXAJAX
AJAX
 
AJAX
AJAXAJAX
AJAX
 
Scalable network applications, event-driven - Node JS
Scalable network applications, event-driven - Node JSScalable network applications, event-driven - Node JS
Scalable network applications, event-driven - Node JS
 
REST & RESTful Web Service
REST & RESTful Web ServiceREST & RESTful Web Service
REST & RESTful Web Service
 
AJAX
AJAXAJAX
AJAX
 
ASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiASP.NET Mvc 4 web api
ASP.NET Mvc 4 web api
 
RESTful SOA - 中科院暑期讲座
RESTful SOA - 中科院暑期讲座RESTful SOA - 中科院暑期讲座
RESTful SOA - 中科院暑期讲座
 
Ajax
AjaxAjax
Ajax
 
Introduction to Ajax programming
Introduction to Ajax programmingIntroduction to Ajax programming
Introduction to Ajax programming
 
Restful web services with java
Restful web services with javaRestful web services with java
Restful web services with java
 
Rest
RestRest
Rest
 
Rest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.jsRest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.js
 

Último

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 

Último (20)

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 

RIA and Ajax

  • 1. Introduction to RIA and AJAX Created by - Schubert [email_address]
  • 2.
  • 3.
  • 4. RIA – Rich Internet Applications
  • 5.
  • 6. Introduction – ii Thick Client – Thin Client Server Client Data Data Data Data Business Logic Presentation Logic Presentation Logic Business Logic Business Logic Presentation Logic UI Engine Business Logic Presentation Logic HTML
  • 7. Introduction - iii The need for smart clients
  • 8. Introduction - iv RIA Richness Communication Application Bringing the Desktop to the Web ! Connected / Alive Interactive Responsive Traditional web Pervasiveness Online / Offline mode Event’s, notification Security Accessibility A RIA
  • 9.
  • 10. Web 2.0 - ii By products
  • 11.
  • 13. HTML – DOM HTML - Are HTML document structures validated ? - <!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01//EN&quot; &quot;http://www.w3.org/TR/html4/strict.dtd&quot;> - What is XHTML ? - HTML 5 and XHTML 5 DOM 
  • 14. CSS CSS Color – Visibility – Positioning - Backgrounds
  • 15. HTTP - i OSI (Open Systems Interconnection) – Reference model Application Presentation Session Transport Network Datalink Physical HTTP Headers Methods Status codes
  • 16.
  • 17. HTTP - iii HTTP methods Get - Conditional GET (if headers such as if-modified-since , etc are present.) - Partial GET (if headers include ranges , avoids data transmission already held by the client) POST - Provide a block of data for processing HEAD - Identical to GET except that the server MUST NOT return a message-body in the response. (used for testing hypertext links for validity, accessibility, and recent modification.) PUT / DELETE / TRACE / CONNECT / OPTIONS
  • 18. HTTP - iv HTTP status codes Informational Success Re - Direction Client Error Server Error 1xx 2xx 3xx 4xx 5xx 100 Continue 200 OK 202 Accepted 301 Moved Permanently 304 Not Modified 400 Bad Request 403 Forbidden 404 Not Found 500 Internal Server Error 502 Bad Gateway 503 Service Unavailable
  • 19.
  • 20. XML / JSON - ii {&quot;menu&quot;: { &quot;id&quot;: &quot;file&quot;, &quot;value&quot;: &quot;File&quot;, &quot;popup&quot;: { &quot;menuitem&quot;: [ {&quot;value&quot;: &quot;New&quot;, &quot;onclick&quot;: &quot;CreateNewDoc()&quot;}, {&quot;value&quot;: &quot;Open&quot;, &quot;onclick&quot;: &quot;OpenDoc()&quot;}, {&quot;value&quot;: &quot;Close&quot;, &quot;onclick&quot;: &quot;CloseDoc()&quot;} ] } }} <menu id=&quot;file&quot; value=&quot;File&quot;> <popup> <menuitem value=&quot;New&quot; onclick=&quot;CreateNewDoc()&quot; /> <menuitem value=&quot;Open&quot; onclick=&quot;OpenDoc()&quot; /> <menuitem value=&quot;Close&quot; onclick=&quot;CloseDoc()&quot; /> </popup> </menu> JSON v/s XML
  • 21. AJAX
  • 22. Introduction AJAX (Asynchronous JavaScript and XML) Ajax can be defined as a group of interrelated web development techniques used to create interactive web applications or rich Internet applications. AJAX CSS / XHTML DOM XML / XSLT XHR Presentation semantics Dynamic display and data interaction Interchange and manipulation Object for communication
  • 23. Introduction - i AJAX interactions – classical web model
  • 24. Introduction - i AJAX interactions – the ajax model
  • 25. The XMLHTTPRequest object - i The XMLHttpRequest Object specification defines an API that provides scripted client functionality for transferring data between a client and a server. The XMLHttpRequest object implements an interface exposed by a scripting engine that allows scripts to perform HTTP client functionality, such as submitting form data or loading data from a server. Supports any text based format, including XML It can be used to make requests over both HTTP and HTTPS Supports all activity involved with HTTP requests or responses for the defined HTTP methods .
  • 26.
  • 27. The XMLHTTPRequest object - iii XHR Object state, events and exceptions XHR Object State UNSENT (Constant value – 0) OPEN (Constant value – 1) SENT (Constant value – 2) LOADING (Constant value – 3) DONE (Constant value – 4) XHR Object Exceptions  XMLHttpRequestException NETWORK_ERR ABORT_ERR XHR Event  readystatechange
  • 28. The XMLHTTPRequest object - iv XHR Object state - elaborated Unsent When constructed, the XMLHttpRequest object must be in the UNSENT state. This state is represented by the UNSENT constant, whose value is 0. Open The OPEN state is the state of the object when the open() method has been successfully invoked. During this state request headers can be set using setRequestHeader() and the request can be made using send(). Sent The SENT state is the state of the object when the user agent successfully acknowledged the request. Loading The LOADING state is the state of the object when all HTTP headers have been received. The object typically remains in this state until the complete message body (if any) has been received. Done The DONE state is the state of the object when either the data transfer has been completed or something went wrong during the transfer.
  • 29. The XMLHTTPRequest object - v XHR methods open(<method>, <url>) This prepares the XHR object for a call to the server. If you are passing parameters with via GET, you can append them to the URL here. send(<body>) This method actually sends the request to the server.  The body parameter can be used to pass any POST parameters that you would like.  You can format your POST parameters just like a GET query-string setRequestHeader(<header>, <value>) This method allows you to set the specified header with the given value. (e.g. content-type) getAllResponseHeaders() Returns all the response headers as a key / value pair. getResponseHeader(<header>) Returns the specific header requested. abort() Aborts the operation
  • 30. The XMLHTTPRequest object - vi XHR properties onreadystatechange This property sets the method to be called on every state change.  This is usually your event handler for the asynchronous callback readyState This property defines the state of the XHR.  Possible values include: 0      Uninitated (open() has not been called) 1      Loading (send() has not been called) 2      Loaded (send() has been called, and headers and status are available.) 3      Interactive (Downloading; responseText holds partial data) 4      Complete (Operation is complete) When sending the XHR, you will check to see if the readyState is 0 or 4, and in your asynchronous callback handler, you will check to see if the readyState is 4. responseText This returns the response from the server as a string. (Typically text, JSON)
  • 31. The XMLHTTPRequest object - vii XHR properties responseXML This returns the response from the server as an XML document.  This is the way to go if you need to return multiple values from your AJAX request. status This returns the HTTP status code from the server such as 200 for OK or 404 for not found. status This returns a string representation of the HTTP status code such as OK for 200 and Not Found for 404
  • 32.
  • 33. AJAX code – decoded - i var xmlHttp = GetXmlHttpObject(); if (xmlHttp==null) { alert (&quot;Your browser does not support AJAX!&quot;); return; } var url = “validate.jsp&quot;; url = url + &quot;?id=“ + str; xmlHttp.onreadystatechange = stateChanged; xmlHttp.open(&quot;GET&quot;,url); xmlHttp.send(null); Function to get the XHR object event handler for the asynchronous callback prepare the XHR object for a call to the server Send the request to the server
  • 34. AJAX code – decoded - ii function stateChanged() { if (xmlHttp.readyState == 4) { if (req.status == 200) { document.getElementById(“validHint&quot;).innerHTML = xmlHttp.responseText; } } } Event handler code
  • 35. AJAX code – decoded - iii function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject(&quot;Msxml2.XMLHTTP&quot;); } catch (e) { xmlHttp=new ActiveXObject(&quot;Microsoft.XMLHTTP&quot;); } } return xmlHttp; } Getting the XHR object Pre 5.5 versions of IE
  • 36. AJAX code – decoded - iv Code overview
  • 37. AJAX code – decoded - v UML overview
  • 38. DOM manipulation concepts var tr = document.createElement('TR'); var td = document.createElement('TD'); tr.appendChild(td); tr.style.backgroundColor = <some color> tr.childNodes tr.firstChild tr.lastChild var parent = td.parentNode; tr.removeChild(td); var img = document.createElement('IMG'); img.setAttribute('src', 'delete.gif'); img.onclick = function() { // function code } Creating elements Adding child elements Setting element properties Referencing child nodes Accessing the parent node Removing parent nodes Assigning behavior to dynamically created elements
  • 39. Basic high-level ajax architecture
  • 41.
  • 43. Frameworks and Toolkits - i Google Web Toolkit
  • 44. Frameworks and Toolkits - ii YUI – Yahoo User Interface
  • 45. Frameworks and Toolkits - iii jMaki
  • 46. Frameworks and Toolkits - iv DEMO Google Web Toolkit (GWT) Yahoo User Interface (YUI) extJS
  • 47. Ajax – Security and Performance related aspects
  • 48.
  • 49.
  • 50.
  • 51. Security issues - iv Preventing direct execution of the Response In order to make it impossible for a malicious site to execute a response that includes JavaScript, the legitimate client application can take advantage of the fact that it is allowed to modify the data it receives before executing it, while a malicious application can only execute it using a <script> tag. When the server serializes an object, it should include a prefix (and potentially a suffix) that makes it impossible to execute the JavaScript using a <script> tag. The legitimate client application can remove this extraneous data before running the JavaScript. Example 1: Prefixing text like while(1) req.open(&quot;GET&quot;, &quot;/object.json&quot;); req.onreadystatechange = function () { if (req.readyState == 4) { var txt = req.responseText; if (txt.substr(0,9) == &quot;while(1);&quot;) { txt = txt.substring(10); } object = eval(&quot;(&quot; + txt + &quot;)&quot;); req = null; } }; Unless the client removes this prefix, evaluating the message will send the JavaScript interpreter into an infinite loop.
  • 52. Security issues - v Preventing direct execution of the Response Example 2: T he server can include comment characters around the JavaScript that have to be removed before the JavaScript is sent to eval() /* [{&quot;fname&quot;:“Larry&quot;, &quot;lname&quot;:“Ellison&quot;, &quot;phone&quot;:&quot;6502135600&quot;, &quot;purchases&quot;:60000.00, &quot;email&quot;:“larry@oracle.com&quot; } ] */ Unless the client removes these comment characters, the JS code will not be able to be evaluated.
  • 53.
  • 54.
  • 55. Ajax – Advantages & Disadvantages
  • 56.
  • 57.
  • 59.
  • 60. Code sample for a Login request <jsp> login.jsp Accept user credentials Login-ajax.js <jsp> validatelogin.jsp JDBC Database 1 2 3 4 5 6 Success / Failure 7 Behind the Scenes – using fire bug
  • 61.