+ All Categories
Home > Documents > IS-907 Java EE World Wide Web - Overview. World Wide Web - History Tim Berners-Lee, CERN, 1990...

IS-907 Java EE World Wide Web - Overview. World Wide Web - History Tim Berners-Lee, CERN, 1990...

Date post: 17-Jan-2016
Category:
Upload: aldous-tyler-hensley
View: 212 times
Download: 0 times
Share this document with a friend
20
IS-907 Java EE World Wide Web - Overview
Transcript
Page 1: IS-907 Java EE World Wide Web - Overview. World Wide Web - History Tim Berners-Lee, CERN, 1990 Enable researchers to share information: Remote Access.

IS-907 Java EEWorld Wide Web - Overview

Page 2: IS-907 Java EE World Wide Web - Overview. World Wide Web - History Tim Berners-Lee, CERN, 1990 Enable researchers to share information: Remote Access.

World Wide Web - History

• Tim Berners-Lee, CERN, 1990

• Enable researchers to share information:• Remote Access• Not restricted to particular type of computer(s)• Non-centralised• Access to existing data• Users can add data• Annotations• Data analysis

Page 3: IS-907 Java EE World Wide Web - Overview. World Wide Web - History Tim Berners-Lee, CERN, 1990 Enable researchers to share information: Remote Access.

Web, Internet, internet...

• internet – connection between local networks

• Internet – the global tcp/ip based internet

• (World Wide) Web/W3 – an http-based application that uses the Internet for data transport

Page 4: IS-907 Java EE World Wide Web - Overview. World Wide Web - History Tim Berners-Lee, CERN, 1990 Enable researchers to share information: Remote Access.

Web Architecture

• The World Wide Web uses a client-server architecture

• Clients (browsers) provides the user interface and displays data

• Servers provide data to the clients on request

• Clients and servers are programs

• The client and server can run on the same computer,or on different computers

• The computer where the server runs is often called host

Page 5: IS-907 Java EE World Wide Web - Overview. World Wide Web - History Tim Berners-Lee, CERN, 1990 Enable researchers to share information: Remote Access.

Building blocks of the web

• http – the HyperText Transfer Protocol: The rules for communication between clients and servers.

• URI/URN/URL – Uniform Resource Identifier/ Name/ Locator: The rules for naming data objects on the web.

• html – HyperText Markup Language: The syntax rules for documents.

Page 6: IS-907 Java EE World Wide Web - Overview. World Wide Web - History Tim Berners-Lee, CERN, 1990 Enable researchers to share information: Remote Access.

HyperText Markup Language

• the document format of the web

• standardized:

• http://www.w3.org/standards/techs/html#w3c_all

• XHTML 1.1

• XHTML 1.0 http://www.w3.org/TR/2002/REC-xhtml1-20020801/

• HTML 4.01 http://www.w3.org/TR/html401/

• XHTML is defined as an XML application

• syntax is stricter than plain HTML

• We will use XHTML 1.0

Even Åby Larsen ([email protected]) IS-102 Introduksjon 6

Page 7: IS-907 Java EE World Wide Web - Overview. World Wide Web - History Tim Berners-Lee, CERN, 1990 Enable researchers to share information: Remote Access.

XHTML pages

• starts with a document declaration:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

• The document contains elements (tags)

• the top level element is html

• all tags must have a matching end tag

<h1>Hello World!</h1>

• the end tag can be abbreviated for empty elements:

<br/>

Even Åby Larsen ([email protected]) IS-102 Introduksjon 7

Page 8: IS-907 Java EE World Wide Web - Overview. World Wide Web - History Tim Berners-Lee, CERN, 1990 Enable researchers to share information: Remote Access.

Simple XHTML page

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>

<head>

<meta http-equiv="Content-Type“

content="text/html; charset=UTF-8" />

<title>Hello</title>

</head>

<body>

<h1>Hello World!</h1>

<p><a href="about.html">About...</a></p>

</body>

</html>

Even Åby Larsen ([email protected]) IS-102 Introduksjon 8

Page 9: IS-907 Java EE World Wide Web - Overview. World Wide Web - History Tim Berners-Lee, CERN, 1990 Enable researchers to share information: Remote Access.

Style sheets

• Used to define the layout and visual properties of html documents

• fonts

• colours

• margins

• ...

• Cascading Style Sheets (css)

• http://www.w3.org/TR/CSS2/

Even Åby Larsen ([email protected]) IS-102 Introduksjon 9

Page 10: IS-907 Java EE World Wide Web - Overview. World Wide Web - History Tim Berners-Lee, CERN, 1990 Enable researchers to share information: Remote Access.

Uniform Resource Locators

• General format: scheme://host/path

• Example: http://java.sun.com/j2se/1.5.0/docs/api/

• scheme = http

• host = java.sun.com

• path = j2se/1.5.0/docs/api

• Relative URL

• path from current page to another one.

• if the page http://mynetshop.com/index.html contains a link to products/computers.html

• it is interpreted by the browser as http://mynetshop.com/products/computers.html

Page 11: IS-907 Java EE World Wide Web - Overview. World Wide Web - History Tim Berners-Lee, CERN, 1990 Enable researchers to share information: Remote Access.

The HyperText Transfer Protocol

• Request / Response protocol

• Message format:

• one or more headers

• blank line

• message body

Client Server

Request

Response

Page 12: IS-907 Java EE World Wide Web - Overview. World Wide Web - History Tim Berners-Lee, CERN, 1990 Enable researchers to share information: Remote Access.

HTTP Request Message types

• GET – used for normal links to get a page, image, ...

• HEAD – just like GET, but no page returned

• POST – used to send data to the server

• PUT – create a new object on the web (seldom used)

• DELETE – remove an object from the web

• TRACE

• OPTIONS

• CONNECT

Page 13: IS-907 Java EE World Wide Web - Overview. World Wide Web - History Tim Berners-Lee, CERN, 1990 Enable researchers to share information: Remote Access.

HTTP GET Request Message Example

GET / j2se/1.5.0/docs/api HTTP/1.1

Host: java.sun.com

Page 14: IS-907 Java EE World Wide Web - Overview. World Wide Web - History Tim Berners-Lee, CERN, 1990 Enable researchers to share information: Remote Access.

HTTP Response Message Example

HTTP/1.1 200 OK

Date: Tue, 28 Aug 2006 07:33:45 GMT

Content-Type: text/html

<html>

html document....

Page 15: IS-907 Java EE World Wide Web - Overview. World Wide Web - History Tim Berners-Lee, CERN, 1990 Enable researchers to share information: Remote Access.

The POST Request

The data from a form are transferred in the request body:

POST /register HTTP/1.1

Host=my.host.com

More=headers

paramname=value

...

Page 16: IS-907 Java EE World Wide Web - Overview. World Wide Web - History Tim Berners-Lee, CERN, 1990 Enable researchers to share information: Remote Access.

Simple web server for static content

while (true) {get next request;read contents of file %DOCROOT%/request.path;create a response message;set response headers;set response.body = file contents;send response;

}

Page 17: IS-907 Java EE World Wide Web - Overview. World Wide Web - History Tim Berners-Lee, CERN, 1990 Enable researchers to share information: Remote Access.

Dynamic web pages

• Dynamic presentation

• uses JavaScript and style sheets

• page remains the same

• user may interact with presentation

• Dynamic content

• server respons with different content depending on input

Page 18: IS-907 Java EE World Wide Web - Overview. World Wide Web - History Tim Berners-Lee, CERN, 1990 Enable researchers to share information: Remote Access.

Dynamic content

• The server doesn’t just map the URL to a filename

• It must

• map the URL to a program,

• run the program,

• and send the output of the program in the body of the response

• the program can do anything:

• get data from a file, or a database

• do some computation

• connect to another system

• ...

Page 19: IS-907 Java EE World Wide Web - Overview. World Wide Web - History Tim Berners-Lee, CERN, 1990 Enable researchers to share information: Remote Access.

Running a program...?• Actually running an external program (CGI)

• the server sends the request to another program

• Server ”plugins” (e.g. servlets)• the server handles the request by calling the plugin code

• Scripts inside the html files (ASP, PHP...)• the server reads a file (just as for static content), but scans the file for

commands, and replaces the commands with the result of executing them

Page 20: IS-907 Java EE World Wide Web - Overview. World Wide Web - History Tim Berners-Lee, CERN, 1990 Enable researchers to share information: Remote Access.

web server for dynamic content

while (true) {get next request;create a response message;if (cgi-url) {

extract program name from request;run the program;set response.body=program output;

}else if (plugin-url) {

call the plugin;set response.body=plugin output;

}else {

read contents of file %ROOT%/request.path;if (file contains script) execute script;set response.body = file contents;

}send response;

}


Recommended