Lecture 13

28
INET 4021 SPRING 2007 Current Network Programming New Technologies April 18, 2007

description

 

Transcript of Lecture 13

Page 1: Lecture 13

INET 4021 SPRING 2007

Current Network Programming

New Technologies

April 18, 2007

Page 2: Lecture 13

INET 4021 SPRING 2007

AJAX (Asynchronous Javascript and XML)

• Interactive way to develop web applications

• Goes beyond CGI into cleaner web UI

• No “full” refresh of entire page

• Started in early browsers, but coined in 2005

• Started as DHTML (Dynamic HTML)

• Main goal is to display pages faster– less data in first get/post

– only get “what you need”, then get more later......

• Ability to get more “rich client” than “thin client”

Page 3: Lecture 13

INET 4021 SPRING 2007

AJAX Advantages/Disadvantages

• Advantages– User Interface – faster loading

– Bandwidth usage – less since you only get what you need

– Separation of data, format, style and function

• Disadvantages– Browser integration

– Response time (what if it takes too long per get?)

– Search engines don't work

– Accessibility

Page 4: Lecture 13

INET 4021 SPRING 2007

AJAX – What is it?

• Javascript – Needed to work “behind the scenes”– Superset of ECMAScript (just more functions)

– Loose typed object oriented scripting language

– Run “in the browser”, meaning “client side”

• DOM – Document Object Model– API for HTML and XML documents

– Language neutral

– Gives programmer access to web page elements

• Put them together...... AJAX

Page 5: Lecture 13

INET 4021 SPRING 2007

AJAX – Code Example

function getTextFromXML( oNode, deep ) { var s = ""; var nodes = oNode.childNodes;

for (var i = 0; i < nodes.length; i++) { var node = nodes[i];

if (node.nodeType == Node.TEXT_NODE) { s += node.data; } else if (deep == true && (node.nodeType == Node.ELEMENT_NODE ||

node.nodeType == Node.DOCUMENT_NODE || node.nodeType == Node.DOCUMENT_FRAGMENT_NODE)) { s += getTextFromXML(node, true); }; }

; return s;}

Page 6: Lecture 13

INET 4021 SPRING 2007

AJAX – Where to Get More Info

• Google Suggest

• Mozilla

• http://www.w3schools.com/ajax

• Simply google AJAX

Page 7: Lecture 13

INET 4021 SPRING 2007

RSS / ATOM

• RSS stands for:– .90 = RDF Site Summary

– .91 = Rich Site Summary

– 2.0.1 = Really Simple Syndication

• ATOM– Took up where RSS left off....

– RSS 2.0 is “frozen” and ATOM extends RSS

Page 8: Lecture 13

INET 4021 SPRING 2007

RSS / ATOM – Compared

• ATOM was designed to solve issues with RSS such as– versioning

– plaintext and escaped HTML in RSS – no way to differentiate

• ATOM:– autodiscovery

– XML namespace & XML schema

– Global unique Ids

– xml:base for relative URIs

Page 9: Lecture 13

INET 4021 SPRING 2007

RSS Example<?xml version="1.0"?><rss version="2.0"> <channel> <title>Liftoff News</title> <link>http://liftoff.msfc.nasa.gov/</link> <description>Liftoff to Space Exploration.</description> <language>en-us</language> <pubDate>Tue, 10 Jun 2003 04:00:00 GMT</pubDate> <lastBuildDate>Tue, 10 Jun 2003 09:41:01 GMT</lastBuildDate> <docs>http://blogs.law.harvard.edu/tech/rss</docs> <generator>Weblog Editor 2.0</generator> <managingEditor>[email protected]</managingEditor> <webMaster>[email protected]</webMaster> <item> <title>Star City</title> <link>http://liftoff.msfc.nasa.gov/news/2003/news-starcity.asp</link> <description>How do Americans get ready to work with Russians aboard the International Space Station? They take a crash course in culture, language and protocol at Russia's Star City.</description> <pubDate>Tue, 03 Jun 2003 09:39:21 GMT</pubDate> <guid>http://liftoff.msfc.nasa.gov/2003/06/03.html#item573</guid> </item>

Page 10: Lecture 13

INET 4021 SPRING 2007

ATOM Example<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom">

<title>Example Feed</title> <subtitle>A subtitle.</subtitle> <link href="http://example.org/"/> <updated>2003-12-13T18:30:02Z</updated> <author> <name>John Doe</name> <email>[email protected]</email> </author> <id>urn:uuid:60a76c80-d399-11d9-b91C-0003939e0af6</id>

<entry> <title>Atom-Powered Robots Run Amok</title> <link href="http://example.org/2003/12/13/atom03"/> <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id> <updated>2003-12-13T18:30:02Z</updated> <summary>Some text.</summary> </entry>

</feed>

Page 11: Lecture 13

INET 4021 SPRING 2007

Servlet Technology

• Around since 1997

• Stems from CGI

• Ability to build applications past simple CGI

• Java

• Allows for client to become Java Objects in server

• Nice abstraction from CGI for – State

– Authentication

– URL re-writing

• Ability to use GET and POST, POST preferred

• WAR file = web application (from tar in Unix, but Web)

Page 12: Lecture 13

INET 4021 SPRING 2007

Servlet Technology – lifecycle of

• Servlet class created from container

• Container calls init() to start (only once)

• Servlet container gets client requests (services) – doGet()

– doPost()

• Container calls destroy() to shutdown

• Each client connection will invoke a Java Object and can be extended to contain many other objects and methods

Page 13: Lecture 13

INET 4021 SPRING 2007

Servlet Technology – Types of Containers

• Non-Commercial– Apache Tomcat – most popular

– Java System Application Server – Sun Microsystems

– Geronimo – Another Apache

• Commercial– BEA WebLogic

– Borland Enterprise Server

– IBM WebSphere

– MacroMedia Jrun

• Commercial Open Source– Jboss – RedHat

Page 14: Lecture 13

INET 4021 SPRING 2007

Servlet Technology – Java Server Pages

• Compiled into Java Servlets

• Used to extend the Servlet API to do whatever you want....

• Components of JSP– Static HTML/XML

– Include directives

– Scripting elements and variables

– JSP Actions

– Tags

Page 15: Lecture 13

INET 4021 SPRING 2007

Servlet Technology – Java Server Pages - Example

// Example of input to a servlet JSP

<%@ page errorPage="myerror.jsp" %> <%@ page import="com.foo.bar" %>

<html> <head> <%! int serverInstanceVariable = 1;%> ... <% int localStackBasedVariable = 1; %> <table> <tr><td><%= "expanded inline data " + 1 %></td></tr> ...

Page 16: Lecture 13

INET 4021 SPRING 2007

Servlet Technology – Java Server Pages - Example//Example Servlet Codeimport com.foo.bar; //imported as a result of <%@ page import="com.foo.bar" %> import ...

class _myservlet implements javax.servlet.Servlet, javax.servlet.jsp.HttpJspPage { //inserted as a //result of <%! int serverInstanceVariable = 1;%> int serverInstanceVariable = 1; ...

public void _jspService( javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response ) throws javax.servlet.ServletException, java.io.IOException { javax.servlet.ServletConfig config = ...;//get the servlet config Object page = this; PageContext pageContext = ...;//get the page context for this request javax.servlet.jsp.JspWriter out = pageContext.getOut(); HttpSession session = request.getSession( true ); try { out.print( "<html>\r\n" ); out.print( "<head>\r\n" ); ... //from <% int localStackBasedVariable = 1; %> int localStackBasedVariable = 1; ... out.print( "<table>\r\n" );

Page 17: Lecture 13

INET 4021 SPRING 2007

Servlet Technology – Java Server Faces

• Technology for creation of User Interfaces

• One of many ways to build UIs– Others include (struts, ASP.NET, Tapestry, etc...)

• Implementations like MyFaces (Apache), Sun RI

• Ability to use “backend beans” for added functionality

• Current trends are merging AJAX to create Dynamic Faces

• Project “GlassFish” - Open Source Java EE 5 Application Server

Page 18: Lecture 13

INET 4021 SPRING 2007

SOA – Service Oriented Architecture

• Architecture that uses loosely coupled services

• Used in technologies such as

– CORBA

– DCOM

– Web Services

• Ability to “connect” to network functions or objects

• Think of it as a general use network based API that is somewhat language neutral

Page 19: Lecture 13

INET 4021 SPRING 2007

SOA – Service Oriented Architecture

Page 20: Lecture 13

INET 4021 SPRING 2007

SOA – Service Oriented Architecture

• Principles

– Reuse, granularity, modularity, composability, componentazation, and interoperability

– Compliance to standards

– Services identification and categorization, provisioning and delivery, monitoring and tracking

• Usually used with SOAP and Web Services

Page 21: Lecture 13

INET 4021 SPRING 2007

Web 2.0 – Putting it all together!

Page 22: Lecture 13

INET 4021 SPRING 2007

Web 2.0 – Putting it all together!

• 2nd Generation of Web Based applications

Page 23: Lecture 13

INET 4021 SPRING 2007

Web 2.0 – Putting it all together!

• Key Principles

– Web as an application platform

– Data is driving force

– Architecture is based on participation

– Innovation by pulling distributed components together

– THE END OF THE SOFTWARE ADOPTION CYCLE!!!!

• (the perpetual BETA program!!)

– Easy to pick up by the early adopters

Page 24: Lecture 13

INET 4021 SPRING 2007

Web 2.0 – Putting it all together!

• Tim O'Reilly “Four plus one” levels of hierarchy

– Level 3 – Applications that ONLY exist on the Internet

• e.g. craigslist, ebay, Wikipedia

– Level 2 – Can live offline, but gain value online

• e.g. Flickr

– Level 1 – Can live offline, but gain features online

• e.g. Google spreadsheets/etc..

– Level 0 – Work as well offline

• e.g. MapQuest, Google Maps

Page 25: Lecture 13

INET 4021 SPRING 2007

Web 2.0 – Futures?

• MAYA Design – Most Advanced, Yet Acceptable

– www.maya.com

– Group formed from 3 Carnegie Mellon University colleagues

– Concept of “Information Commons”

– Trying to reduce complexity of data

• Internet Zero – MIT Center for Bits and Atoms

– Emerging standard for connecting everything

– IP in the physical world

– Multi-disciplinary team and approach

Page 26: Lecture 13

INET 4021 SPRING 2007

SaaS (Software as a Service)

• SaaS – salesforce.com – CRM example

• Reduces the need for:• Capital expenditures • Maintenance costs• Upgrade (hardware and software)• Integration (possibly)

• Negative• You get what you get• Usually not a good integration point

Page 27: Lecture 13

INET 4021 SPRING 2007

SaaS (Software as a Service)

• SaaS – salesforce.com – CRM example

• Reduces the need for:• Capital expenditures • Maintenance costs• Upgrade (hardware and software)• Integration (possibly)

• Negative• You get what you get• Usually not a good integration point

Page 28: Lecture 13

INET 4021 SPRING 2007

Mashups

• Ability to plug in web2.0 components into a single page

• Normally seen in Wiki pages• Current examples:

• www.mapdango.com• Technologies to mash

• Facebook• Twitter• YouTube• Google• Wikis