Basic Internet Programming

101
Internet Content Internet content HTML SGML CSS XML XHTML MIME HTTP DD1335 (Lecture 2) Basic Internet Programming Spring 2010 1 / 27

Transcript of Basic Internet Programming

Page 1: Basic Internet Programming

Internet Content

Internet content

HTMLSGMLCSSXML

XHTMLMIMEHTTP

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 1 / 27

Page 2: Basic Internet Programming

Internet Content

Objectives

I What HTML is, what its origins are, and where one can find informationabout it

I Next generation HTML: CSS, XHTMLI Describing internet data: XMLI Understanding how different types of content are dealt with in the Internet

(MIME)I HTTP, internet protocols, proxies

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 2 / 27

Page 3: Basic Internet Programming

Internet Content

Objectives

I What HTML is, what its origins are, and where one can find informationabout it

I Next generation HTML: CSS, XHTML

I Describing internet data: XMLI Understanding how different types of content are dealt with in the Internet

(MIME)I HTTP, internet protocols, proxies

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 2 / 27

Page 4: Basic Internet Programming

Internet Content

Objectives

I What HTML is, what its origins are, and where one can find informationabout it

I Next generation HTML: CSS, XHTMLI Describing internet data: XML

I Understanding how different types of content are dealt with in the Internet(MIME)

I HTTP, internet protocols, proxies

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 2 / 27

Page 5: Basic Internet Programming

Internet Content

Objectives

I What HTML is, what its origins are, and where one can find informationabout it

I Next generation HTML: CSS, XHTMLI Describing internet data: XMLI Understanding how different types of content are dealt with in the Internet

(MIME)

I HTTP, internet protocols, proxies

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 2 / 27

Page 6: Basic Internet Programming

Internet Content

Objectives

I What HTML is, what its origins are, and where one can find informationabout it

I Next generation HTML: CSS, XHTMLI Describing internet data: XMLI Understanding how different types of content are dealt with in the Internet

(MIME)I HTTP, internet protocols, proxies

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 2 / 27

Page 7: Basic Internet Programming

Internet Content

HTML & SGML

I HyperText Markup Language

I Markup:I Classic usage: editing <b>marked up text</b>I Correcting, data description and other usages

I Markup languages have a long historyI troff, nroff (for unix man pages), runoffI TeX, LaTeX, excellent to write books with (Knuth) and slides (eg. these

slides)I SGML, the origin of HTML, looks like today’s XML. SGML and XML

describes data

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 3 / 27

Page 8: Basic Internet Programming

Internet Content

HTML & SGML

I HyperText Markup LanguageI Markup:

I Classic usage: editing <b>marked up text</b>I Correcting, data description and other usages

I Markup languages have a long historyI troff, nroff (for unix man pages), runoffI TeX, LaTeX, excellent to write books with (Knuth) and slides (eg. these

slides)I SGML, the origin of HTML, looks like today’s XML. SGML and XML

describes data

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 3 / 27

Page 9: Basic Internet Programming

Internet Content

HTML & SGML

I HyperText Markup LanguageI Markup:

I Classic usage: editing <b>marked up text</b>I Correcting, data description and other usages

I Markup languages have a long historyI troff, nroff (for unix man pages), runoff

I TeX, LaTeX, excellent to write books with (Knuth) and slides (eg. theseslides)

I SGML, the origin of HTML, looks like today’s XML. SGML and XMLdescribes data

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 3 / 27

Page 10: Basic Internet Programming

Internet Content

HTML & SGML

I HyperText Markup LanguageI Markup:

I Classic usage: editing <b>marked up text</b>I Correcting, data description and other usages

I Markup languages have a long historyI troff, nroff (for unix man pages), runoffI TeX, LaTeX, excellent to write books with (Knuth) and slides (eg. these

slides)

I SGML, the origin of HTML, looks like today’s XML. SGML and XMLdescribes data

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 3 / 27

Page 11: Basic Internet Programming

Internet Content

HTML & SGML

I HyperText Markup LanguageI Markup:

I Classic usage: editing <b>marked up text</b>I Correcting, data description and other usages

I Markup languages have a long historyI troff, nroff (for unix man pages), runoffI TeX, LaTeX, excellent to write books with (Knuth) and slides (eg. these

slides)I SGML, the origin of HTML, looks like today’s XML. SGML and XML

describes data

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 3 / 27

Page 12: Basic Internet Programming

Internet Content

SGML/XML-example

<email><sender>

<person><id>[email protected]</id><christianname>Serafim</christianname><familyname>Dahl</familyname>

</person></sender><reciever>

<person><distributionlist>DD1335;[email protected]</distributionlist>

</person></reciever><contents>

It’s ugly, isn’t it?</contents>

</email>

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 4 / 27

Page 13: Basic Internet Programming

Internet Content

SGML/XML-example . . .

I The example describes just data

I It says nothing about presentation (color, font, alignment, . . . )I All text is inside a <tag>text</tag>

I There is a separate document that specifies what tags are allowed in theSGML document, in what order are they allowed, etc. Can be used tovalidate the SGML

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 5 / 27

Page 14: Basic Internet Programming

Internet Content

SGML/XML-example . . .

I The example describes just dataI It says nothing about presentation (color, font, alignment, . . . )

I All text is inside a <tag>text</tag>

I There is a separate document that specifies what tags are allowed in theSGML document, in what order are they allowed, etc. Can be used tovalidate the SGML

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 5 / 27

Page 15: Basic Internet Programming

Internet Content

SGML/XML-example . . .

I The example describes just dataI It says nothing about presentation (color, font, alignment, . . . )I All text is inside a <tag>text</tag>

I There is a separate document that specifies what tags are allowed in theSGML document, in what order are they allowed, etc. Can be used tovalidate the SGML

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 5 / 27

Page 16: Basic Internet Programming

Internet Content

SGML/XML-example . . .

I The example describes just dataI It says nothing about presentation (color, font, alignment, . . . )I All text is inside a <tag>text</tag>

I There is a separate document that specifies what tags are allowed in theSGML document, in what order are they allowed, etc. Can be used tovalidate the SGML

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 5 / 27

Page 17: Basic Internet Programming

Internet Content

DTD, Document Type Definition

<!doctype email[<!element email (sender,reciever,contents)><!element sender (person)><!element reciever (person)+><!element person (distributionlist) |

(christianname, middlename?,familyname)><!element (christianname, middlename?,familyname)

(#PCDATA)><!element distributionlist (#PCDATA)><!element contents (#PCDATA)>

]>

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 6 / 27

Page 18: Basic Internet Programming

Internet Content

DTD, Document Type Definition

<!doctype email[

<!element email (sender,reciever,contents)><!element sender (person)><!element reciever (person)+><!element person (distributionlist) |

(christianname, middlename?,familyname)><!element (christianname, middlename?,familyname)

(#PCDATA)><!element distributionlist (#PCDATA)><!element contents (#PCDATA)>

]>

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 6 / 27

Page 19: Basic Internet Programming

Internet Content

DTD, Document Type Definition

<!doctype email[<!element email (sender,reciever,contents)>

<!element sender (person)><!element reciever (person)+><!element person (distributionlist) |

(christianname, middlename?,familyname)><!element (christianname, middlename?,familyname)

(#PCDATA)><!element distributionlist (#PCDATA)><!element contents (#PCDATA)>

]>

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 6 / 27

Page 20: Basic Internet Programming

Internet Content

DTD, Document Type Definition

<!doctype email[<!element email (sender,reciever,contents)><!element sender (person)><!element reciever (person)+>

<!element person (distributionlist) |(christianname, middlename?,familyname)>

<!element (christianname, middlename?,familyname)(#PCDATA)>

<!element distributionlist (#PCDATA)>

<!element contents (#PCDATA)>

]>

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 6 / 27

Page 21: Basic Internet Programming

Internet Content

DTD, Document Type Definition

<!doctype email[<!element email (sender,reciever,contents)><!element sender (person)><!element reciever (person)+><!element person (distributionlist) |

(christianname, middlename?,familyname)>

<!element (christianname, middlename?,familyname)(#PCDATA)>

<!element distributionlist (#PCDATA)>

<!element contents (#PCDATA)>

]>

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 6 / 27

Page 22: Basic Internet Programming

Internet Content

DTD, Document Type Definition

<!doctype email[<!element email (sender,reciever,contents)><!element sender (person)><!element reciever (person)+><!element person (distributionlist) |

(christianname, middlename?,familyname)><!element (christianname, middlename?,familyname)

(#PCDATA)><!element distributionlist (#PCDATA)><!element contents (#PCDATA)>

]>

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 6 / 27

Page 23: Basic Internet Programming

Internet Content

HTML

I Describes how webpages are visualised

I A “web browser” reads the description and interprets it or (when there isno description) uses a default interpretation

I early version 1965 in Douglas Englebart’s “oNLine System”, NLSI Tim Bernes-Lee at CERN made ENQUIRE in 1980, which developed into

HTML and present presentation techniques.I HTML is developped and maintained by W3C (World Wide Web

Consortium)I HTML, CSS, XHTML, XMLI Most common is HTML 4.0 (default)I Latest version is XHTML 1.1

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 7 / 27

Page 24: Basic Internet Programming

Internet Content

HTML

I Describes how webpages are visualisedI A “web browser” reads the description and interprets it or (when there is

no description) uses a default interpretation

I early version 1965 in Douglas Englebart’s “oNLine System”, NLSI Tim Bernes-Lee at CERN made ENQUIRE in 1980, which developed into

HTML and present presentation techniques.I HTML is developped and maintained by W3C (World Wide Web

Consortium)I HTML, CSS, XHTML, XMLI Most common is HTML 4.0 (default)I Latest version is XHTML 1.1

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 7 / 27

Page 25: Basic Internet Programming

Internet Content

HTML

I Describes how webpages are visualisedI A “web browser” reads the description and interprets it or (when there is

no description) uses a default interpretationI early version 1965 in Douglas Englebart’s “oNLine System”, NLS

I Tim Bernes-Lee at CERN made ENQUIRE in 1980, which developed intoHTML and present presentation techniques.

I HTML is developped and maintained by W3C (World Wide WebConsortium)

I HTML, CSS, XHTML, XMLI Most common is HTML 4.0 (default)I Latest version is XHTML 1.1

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 7 / 27

Page 26: Basic Internet Programming

Internet Content

HTML

I Describes how webpages are visualisedI A “web browser” reads the description and interprets it or (when there is

no description) uses a default interpretationI early version 1965 in Douglas Englebart’s “oNLine System”, NLSI Tim Bernes-Lee at CERN made ENQUIRE in 1980, which developed into

HTML and present presentation techniques.

I HTML is developped and maintained by W3C (World Wide WebConsortium)

I HTML, CSS, XHTML, XMLI Most common is HTML 4.0 (default)I Latest version is XHTML 1.1

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 7 / 27

Page 27: Basic Internet Programming

Internet Content

HTML

I Describes how webpages are visualisedI A “web browser” reads the description and interprets it or (when there is

no description) uses a default interpretationI early version 1965 in Douglas Englebart’s “oNLine System”, NLSI Tim Bernes-Lee at CERN made ENQUIRE in 1980, which developed into

HTML and present presentation techniques.I HTML is developped and maintained by W3C (World Wide Web

Consortium)

I HTML, CSS, XHTML, XMLI Most common is HTML 4.0 (default)I Latest version is XHTML 1.1

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 7 / 27

Page 28: Basic Internet Programming

Internet Content

HTML

I Describes how webpages are visualisedI A “web browser” reads the description and interprets it or (when there is

no description) uses a default interpretationI early version 1965 in Douglas Englebart’s “oNLine System”, NLSI Tim Bernes-Lee at CERN made ENQUIRE in 1980, which developed into

HTML and present presentation techniques.I HTML is developped and maintained by W3C (World Wide Web

Consortium)I HTML, CSS, XHTML, XML

I Most common is HTML 4.0 (default)I Latest version is XHTML 1.1

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 7 / 27

Page 29: Basic Internet Programming

Internet Content

HTML

I Describes how webpages are visualisedI A “web browser” reads the description and interprets it or (when there is

no description) uses a default interpretationI early version 1965 in Douglas Englebart’s “oNLine System”, NLSI Tim Bernes-Lee at CERN made ENQUIRE in 1980, which developed into

HTML and present presentation techniques.I HTML is developped and maintained by W3C (World Wide Web

Consortium)I HTML, CSS, XHTML, XMLI Most common is HTML 4.0 (default)

I Latest version is XHTML 1.1

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 7 / 27

Page 30: Basic Internet Programming

Internet Content

HTML

I Describes how webpages are visualisedI A “web browser” reads the description and interprets it or (when there is

no description) uses a default interpretationI early version 1965 in Douglas Englebart’s “oNLine System”, NLSI Tim Bernes-Lee at CERN made ENQUIRE in 1980, which developed into

HTML and present presentation techniques.I HTML is developped and maintained by W3C (World Wide Web

Consortium)I HTML, CSS, XHTML, XMLI Most common is HTML 4.0 (default)I Latest version is XHTML 1.1

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 7 / 27

Page 31: Basic Internet Programming

Internet Content

HTML . . .

<html><head><title>HTML</title></head><body><!- the line above may be omitted ->

<h1>HTML</h1><p>This is a short presentation of <b><u>HTML</u></b>. Its

main points:</p><ul>

<li>Unlike SGML and XML, HTML describes how data is<i>presented</i>, not what the data <i>is</i>. It is thusan editing markup, much like<a href="http://www.tex.ac.uk/cgi-bin/texfaq2html">TeX</a><ul>

<li>There can be text outside any tag, and though itwon’t be validated, it will &quot;work&quot;</li>

<li>You can’t write a validator document</li><li>If a HTML document is invalid e.g. by not having

correct tag order, or missing tags, it will be presentedanyway. A closing tag is missing right here

</ul></li><li>As in other markup languages, some tags can only appear

inside other tags (e.g. &lt;li&gt; can only appear inside&lt;body&gt;)</li><li> A text fragment in a document can link to other

documents, or to a specific place in the document.</li></ul>

</body></html>

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 8 / 27

Page 32: Basic Internet Programming

Internet Content

will look like:

HTMLThis is a short presentation of HTML. Its main points:

• Unlike SGML and XML, HTML describes how data is presented not what the datais. It is thus an editing markup, much like TeX

◦ There can be text outside any tag, though this won’t be validated, it will”work”

◦ You can’t write a validator document◦ If a HTML document is invalid e.g. by not having correct tag order, or missing

tags, it will be presented anyway. A closing tag is missing right here

• As in other markup languages, some tags can only appear inside other tags (e.g.<li> can only appear inside <body>)

• A text fragment in a document can link to other documents, or to a specific placein the document.

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 9 / 27

Page 33: Basic Internet Programming

Internet Content

XHTML

<?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>XHTML</title>

</head><body><h1>XHTML</h1><p>This is a short presentation of <b><u>XHTML</u></b>. Its main points:</p><ul><li>Unlike SGML and XML, XHTML describes how data is

<i>presented</i> not what the data <i>is</i>. It is thus an editingmarkup, much like <a href="http://www.ctan.org/">TeX</a>

<ul><li>There can be text outside any tag, though this won’t be validated,it will &quot;work&quot;</li>

<li>You can’t write a validator document</li><li>If an XHTML document is invalid there will be an error message

A closing tag is missing right here</ul></li>

<li>As in other markup languages, some tags can only appear insideother tags (e.g. <li> can only appear inside <body>)</li>

<li>A text fragment in a document can link to other documents, or to aspecific place in the document.</li>

</ul></body></html>

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 10 / 27

Page 34: Basic Internet Programming

Internet Content

XHTML - result

XML Interpreter error: mismatched tag. Expected: </li>.Adress: http://www.csc.kth.se/~serafim/02-internet-content.xhtmlRadnummer 22, Kolumn 9:

</ul>-----^

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 11 / 27

Page 35: Basic Internet Programming

Internet Content

HTML tags

I HTML reference: http://www.htmlhelp.com/reference/html40/I HTML referece:

http://www.webreference.com/authoring/languages/html/

I XHTML referece:http://www.webreference.com/authoring/languages/xhtml/

I Also on http://www.w3schools.com/ where there are links to otherplaces

I Organizational list of HTML tagshttp://www.htmlhelp.com/reference/html40/olist.html

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 12 / 27

Page 36: Basic Internet Programming

Internet Content

HTML tags . . .

I Parts of an HTML document:I the header contains general information about the document e.g. the title,

author, document generator, . . .

I the body contains the document content orI a frameset that describes a set of framesI If the header is missing, the whole content is interpreted as body

I The tag <a> with the attribute href denotes a link. The link may beabsolute or relative. It is good practice to use relative links to pages in thesame site, because then moving the site to another server or directory iseasy

I <a href="document-in-same-directory.html">. . .I <a href="directory/dokument.html">. . .I <a href="../another-directory/another-doc.html">. . .I BASE can be used to indicate the base for all relative links

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 13 / 27

Page 37: Basic Internet Programming

Internet Content

HTML tags . . .

I Parts of an HTML document:I the header contains general information about the document e.g. the title,

author, document generator, . . .I the body contains the document content or

I a frameset that describes a set of framesI If the header is missing, the whole content is interpreted as body

I The tag <a> with the attribute href denotes a link. The link may beabsolute or relative. It is good practice to use relative links to pages in thesame site, because then moving the site to another server or directory iseasy

I <a href="document-in-same-directory.html">. . .I <a href="directory/dokument.html">. . .I <a href="../another-directory/another-doc.html">. . .I BASE can be used to indicate the base for all relative links

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 13 / 27

Page 38: Basic Internet Programming

Internet Content

HTML tags . . .

I Parts of an HTML document:I the header contains general information about the document e.g. the title,

author, document generator, . . .I the body contains the document content orI a frameset that describes a set of frames

I If the header is missing, the whole content is interpreted as bodyI The tag <a> with the attribute href denotes a link. The link may be

absolute or relative. It is good practice to use relative links to pages in thesame site, because then moving the site to another server or directory iseasy

I <a href="document-in-same-directory.html">. . .I <a href="directory/dokument.html">. . .I <a href="../another-directory/another-doc.html">. . .I BASE can be used to indicate the base for all relative links

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 13 / 27

Page 39: Basic Internet Programming

Internet Content

HTML tags . . .

I Parts of an HTML document:I the header contains general information about the document e.g. the title,

author, document generator, . . .I the body contains the document content orI a frameset that describes a set of framesI If the header is missing, the whole content is interpreted as body

I The tag <a> with the attribute href denotes a link. The link may beabsolute or relative. It is good practice to use relative links to pages in thesame site, because then moving the site to another server or directory iseasy

I <a href="document-in-same-directory.html">. . .I <a href="directory/dokument.html">. . .I <a href="../another-directory/another-doc.html">. . .I BASE can be used to indicate the base for all relative links

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 13 / 27

Page 40: Basic Internet Programming

Internet Content

HTML tags . . .

I Parts of an HTML document:I the header contains general information about the document e.g. the title,

author, document generator, . . .I the body contains the document content orI a frameset that describes a set of framesI If the header is missing, the whole content is interpreted as body

I The tag <a> with the attribute href denotes a link. The link may beabsolute or relative. It is good practice to use relative links to pages in thesame site, because then moving the site to another server or directory iseasy

I <a href="document-in-same-directory.html">. . .I <a href="directory/dokument.html">. . .I <a href="../another-directory/another-doc.html">. . .I BASE can be used to indicate the base for all relative links

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 13 / 27

Page 41: Basic Internet Programming

Internet Content

HTML tags . . .

I Parts of an HTML document:I the header contains general information about the document e.g. the title,

author, document generator, . . .I the body contains the document content orI a frameset that describes a set of framesI If the header is missing, the whole content is interpreted as body

I The tag <a> with the attribute href denotes a link. The link may beabsolute or relative. It is good practice to use relative links to pages in thesame site, because then moving the site to another server or directory iseasy

I <a href="document-in-same-directory.html">. . .

I <a href="directory/dokument.html">. . .I <a href="../another-directory/another-doc.html">. . .I BASE can be used to indicate the base for all relative links

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 13 / 27

Page 42: Basic Internet Programming

Internet Content

HTML tags . . .

I Parts of an HTML document:I the header contains general information about the document e.g. the title,

author, document generator, . . .I the body contains the document content orI a frameset that describes a set of framesI If the header is missing, the whole content is interpreted as body

I The tag <a> with the attribute href denotes a link. The link may beabsolute or relative. It is good practice to use relative links to pages in thesame site, because then moving the site to another server or directory iseasy

I <a href="document-in-same-directory.html">. . .I <a href="directory/dokument.html">. . .

I <a href="../another-directory/another-doc.html">. . .I BASE can be used to indicate the base for all relative links

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 13 / 27

Page 43: Basic Internet Programming

Internet Content

HTML tags . . .

I Parts of an HTML document:I the header contains general information about the document e.g. the title,

author, document generator, . . .I the body contains the document content orI a frameset that describes a set of framesI If the header is missing, the whole content is interpreted as body

I The tag <a> with the attribute href denotes a link. The link may beabsolute or relative. It is good practice to use relative links to pages in thesame site, because then moving the site to another server or directory iseasy

I <a href="document-in-same-directory.html">. . .I <a href="directory/dokument.html">. . .I <a href="../another-directory/another-doc.html">. . .

I BASE can be used to indicate the base for all relative links

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 13 / 27

Page 44: Basic Internet Programming

Internet Content

HTML tags . . .

I Parts of an HTML document:I the header contains general information about the document e.g. the title,

author, document generator, . . .I the body contains the document content orI a frameset that describes a set of framesI If the header is missing, the whole content is interpreted as body

I The tag <a> with the attribute href denotes a link. The link may beabsolute or relative. It is good practice to use relative links to pages in thesame site, because then moving the site to another server or directory iseasy

I <a href="document-in-same-directory.html">. . .I <a href="directory/dokument.html">. . .I <a href="../another-directory/another-doc.html">. . .I BASE can be used to indicate the base for all relative links

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 13 / 27

Page 45: Basic Internet Programming

Internet Content

HTML tags . . .

I Other useful head tags: title (most used)

I Later: meta (used to simulate HTTP headers)I style used to change the outlook of a document eg. by using cascading style

sheets (CSS)I In the body: <p>...</p> denotes a paragraph. If there’s no tag around a text

fragment, the default is <p>...</p>. Use <br> or <br /> for a line break.I Anchors: <a name="here"> marks a place in the document that can be

accessed using documentname#here likehttp://www.csc.kth.se/utbildning/kth/kurser/DD1335/index.php#start

I <h1> </h1> ... <h6> </h6> are heading levelsI If you want spaces and newlines to matter, use: <pre> </pre>

I Text appearance can be changed like in text editors with <b>, <i>, <font>,<big>, <small>, <sub>, <tt>, <s>. The modern choise is to use style,mandatory in XHTML, wise even in HTML.

I Tables <table>, table rows <tr>, table headers <th>, table cell <td>

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 14 / 27

Page 46: Basic Internet Programming

Internet Content

HTML tags . . .

I Other useful head tags: title (most used)I Later: meta (used to simulate HTTP headers)

I style used to change the outlook of a document eg. by using cascading stylesheets (CSS)

I In the body: <p>...</p> denotes a paragraph. If there’s no tag around a textfragment, the default is <p>...</p>. Use <br> or <br /> for a line break.

I Anchors: <a name="here"> marks a place in the document that can beaccessed using documentname#here likehttp://www.csc.kth.se/utbildning/kth/kurser/DD1335/index.php#start

I <h1> </h1> ... <h6> </h6> are heading levelsI If you want spaces and newlines to matter, use: <pre> </pre>

I Text appearance can be changed like in text editors with <b>, <i>, <font>,<big>, <small>, <sub>, <tt>, <s>. The modern choise is to use style,mandatory in XHTML, wise even in HTML.

I Tables <table>, table rows <tr>, table headers <th>, table cell <td>

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 14 / 27

Page 47: Basic Internet Programming

Internet Content

HTML tags . . .

I Other useful head tags: title (most used)I Later: meta (used to simulate HTTP headers)I style used to change the outlook of a document eg. by using cascading style

sheets (CSS)

I In the body: <p>...</p> denotes a paragraph. If there’s no tag around a textfragment, the default is <p>...</p>. Use <br> or <br /> for a line break.

I Anchors: <a name="here"> marks a place in the document that can beaccessed using documentname#here likehttp://www.csc.kth.se/utbildning/kth/kurser/DD1335/index.php#start

I <h1> </h1> ... <h6> </h6> are heading levelsI If you want spaces and newlines to matter, use: <pre> </pre>

I Text appearance can be changed like in text editors with <b>, <i>, <font>,<big>, <small>, <sub>, <tt>, <s>. The modern choise is to use style,mandatory in XHTML, wise even in HTML.

I Tables <table>, table rows <tr>, table headers <th>, table cell <td>

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 14 / 27

Page 48: Basic Internet Programming

Internet Content

HTML tags . . .

I Other useful head tags: title (most used)I Later: meta (used to simulate HTTP headers)I style used to change the outlook of a document eg. by using cascading style

sheets (CSS)I In the body: <p>...</p> denotes a paragraph. If there’s no tag around a text

fragment, the default is <p>...</p>. Use <br> or <br /> for a line break.

I Anchors: <a name="here"> marks a place in the document that can beaccessed using documentname#here likehttp://www.csc.kth.se/utbildning/kth/kurser/DD1335/index.php#start

I <h1> </h1> ... <h6> </h6> are heading levelsI If you want spaces and newlines to matter, use: <pre> </pre>

I Text appearance can be changed like in text editors with <b>, <i>, <font>,<big>, <small>, <sub>, <tt>, <s>. The modern choise is to use style,mandatory in XHTML, wise even in HTML.

I Tables <table>, table rows <tr>, table headers <th>, table cell <td>

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 14 / 27

Page 49: Basic Internet Programming

Internet Content

HTML tags . . .

I Other useful head tags: title (most used)I Later: meta (used to simulate HTTP headers)I style used to change the outlook of a document eg. by using cascading style

sheets (CSS)I In the body: <p>...</p> denotes a paragraph. If there’s no tag around a text

fragment, the default is <p>...</p>. Use <br> or <br /> for a line break.I Anchors: <a name="here"> marks a place in the document that can be

accessed using documentname#here likehttp://www.csc.kth.se/utbildning/kth/kurser/DD1335/index.php#start

I <h1> </h1> ... <h6> </h6> are heading levelsI If you want spaces and newlines to matter, use: <pre> </pre>

I Text appearance can be changed like in text editors with <b>, <i>, <font>,<big>, <small>, <sub>, <tt>, <s>. The modern choise is to use style,mandatory in XHTML, wise even in HTML.

I Tables <table>, table rows <tr>, table headers <th>, table cell <td>

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 14 / 27

Page 50: Basic Internet Programming

Internet Content

HTML tags . . .

I Other useful head tags: title (most used)I Later: meta (used to simulate HTTP headers)I style used to change the outlook of a document eg. by using cascading style

sheets (CSS)I In the body: <p>...</p> denotes a paragraph. If there’s no tag around a text

fragment, the default is <p>...</p>. Use <br> or <br /> for a line break.I Anchors: <a name="here"> marks a place in the document that can be

accessed using documentname#here likehttp://www.csc.kth.se/utbildning/kth/kurser/DD1335/index.php#start

I <h1> </h1> ... <h6> </h6> are heading levels

I If you want spaces and newlines to matter, use: <pre> </pre>

I Text appearance can be changed like in text editors with <b>, <i>, <font>,<big>, <small>, <sub>, <tt>, <s>. The modern choise is to use style,mandatory in XHTML, wise even in HTML.

I Tables <table>, table rows <tr>, table headers <th>, table cell <td>

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 14 / 27

Page 51: Basic Internet Programming

Internet Content

HTML tags . . .

I Other useful head tags: title (most used)I Later: meta (used to simulate HTTP headers)I style used to change the outlook of a document eg. by using cascading style

sheets (CSS)I In the body: <p>...</p> denotes a paragraph. If there’s no tag around a text

fragment, the default is <p>...</p>. Use <br> or <br /> for a line break.I Anchors: <a name="here"> marks a place in the document that can be

accessed using documentname#here likehttp://www.csc.kth.se/utbildning/kth/kurser/DD1335/index.php#start

I <h1> </h1> ... <h6> </h6> are heading levelsI If you want spaces and newlines to matter, use: <pre> </pre>

I Text appearance can be changed like in text editors with <b>, <i>, <font>,<big>, <small>, <sub>, <tt>, <s>. The modern choise is to use style,mandatory in XHTML, wise even in HTML.

I Tables <table>, table rows <tr>, table headers <th>, table cell <td>

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 14 / 27

Page 52: Basic Internet Programming

Internet Content

HTML tags . . .

I Other useful head tags: title (most used)I Later: meta (used to simulate HTTP headers)I style used to change the outlook of a document eg. by using cascading style

sheets (CSS)I In the body: <p>...</p> denotes a paragraph. If there’s no tag around a text

fragment, the default is <p>...</p>. Use <br> or <br /> for a line break.I Anchors: <a name="here"> marks a place in the document that can be

accessed using documentname#here likehttp://www.csc.kth.se/utbildning/kth/kurser/DD1335/index.php#start

I <h1> </h1> ... <h6> </h6> are heading levelsI If you want spaces and newlines to matter, use: <pre> </pre>

I Text appearance can be changed like in text editors with <b>, <i>, <font>,<big>, <small>, <sub>, <tt>, <s>. The modern choise is to use style,mandatory in XHTML, wise even in HTML.

I Tables <table>, table rows <tr>, table headers <th>, table cell <td>

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 14 / 27

Page 53: Basic Internet Programming

Internet Content

HTML tags . . .

I Other useful head tags: title (most used)I Later: meta (used to simulate HTTP headers)I style used to change the outlook of a document eg. by using cascading style

sheets (CSS)I In the body: <p>...</p> denotes a paragraph. If there’s no tag around a text

fragment, the default is <p>...</p>. Use <br> or <br /> for a line break.I Anchors: <a name="here"> marks a place in the document that can be

accessed using documentname#here likehttp://www.csc.kth.se/utbildning/kth/kurser/DD1335/index.php#start

I <h1> </h1> ... <h6> </h6> are heading levelsI If you want spaces and newlines to matter, use: <pre> </pre>

I Text appearance can be changed like in text editors with <b>, <i>, <font>,<big>, <small>, <sub>, <tt>, <s>. The modern choise is to use style,mandatory in XHTML, wise even in HTML.

I Tables <table>, table rows <tr>, table headers <th>, table cell <td>

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 14 / 27

Page 54: Basic Internet Programming

Internet Content

HTML tools

On the web there are many application programs that can be used to checkyour (X)HTML documents, even to upgrade them to later standards

I http://www.htmlhelp.com/tools/validator/

I http://sourceforge.net/projects/tidy/

I http://jigsaw.w3.org/css-validator/

I http://www.thefreecountry.com/webmaster/htmleditors.shtml

There are also development systems for HTML/CSS/PHP/EJB offeringextensive help and support when programming for the web, on Linux e.g.

I BlueFishI Quanta+I Eclipse (for all platforms and most languages)I Netbeans (for all platforms and many languages)

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 15 / 27

Page 55: Basic Internet Programming

Internet Content

HTML tools

On the web there are many application programs that can be used to checkyour (X)HTML documents, even to upgrade them to later standards

I http://www.htmlhelp.com/tools/validator/

I http://sourceforge.net/projects/tidy/

I http://jigsaw.w3.org/css-validator/

I http://www.thefreecountry.com/webmaster/htmleditors.shtml

There are also development systems for HTML/CSS/PHP/EJB offeringextensive help and support when programming for the web, on Linux e.g.

I BlueFishI Quanta+I Eclipse (for all platforms and most languages)I Netbeans (for all platforms and many languages)

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 15 / 27

Page 56: Basic Internet Programming

Internet Content

HTML tools

On the web there are many application programs that can be used to checkyour (X)HTML documents, even to upgrade them to later standards

I http://www.htmlhelp.com/tools/validator/

I http://sourceforge.net/projects/tidy/

I http://jigsaw.w3.org/css-validator/

I http://www.thefreecountry.com/webmaster/htmleditors.shtml

There are also development systems for HTML/CSS/PHP/EJB offeringextensive help and support when programming for the web, on Linux e.g.

I BlueFishI Quanta+I Eclipse (for all platforms and most languages)I Netbeans (for all platforms and many languages)

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 15 / 27

Page 57: Basic Internet Programming

Internet Content

HTML tools

On the web there are many application programs that can be used to checkyour (X)HTML documents, even to upgrade them to later standards

I http://www.htmlhelp.com/tools/validator/

I http://sourceforge.net/projects/tidy/

I http://jigsaw.w3.org/css-validator/

I http://www.thefreecountry.com/webmaster/htmleditors.shtml

There are also development systems for HTML/CSS/PHP/EJB offeringextensive help and support when programming for the web, on Linux e.g.

I BlueFishI Quanta+I Eclipse (for all platforms and most languages)I Netbeans (for all platforms and many languages)

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 15 / 27

Page 58: Basic Internet Programming

Internet Content

HTML tools

On the web there are many application programs that can be used to checkyour (X)HTML documents, even to upgrade them to later standards

I http://www.htmlhelp.com/tools/validator/

I http://sourceforge.net/projects/tidy/

I http://jigsaw.w3.org/css-validator/

I http://www.thefreecountry.com/webmaster/htmleditors.shtml

There are also development systems for HTML/CSS/PHP/EJB offeringextensive help and support when programming for the web, on Linux e.g.

I BlueFishI Quanta+I Eclipse (for all platforms and most languages)I Netbeans (for all platforms and many languages)

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 15 / 27

Page 59: Basic Internet Programming

Internet Content

Style / Cascading Style Sheets (CSS)

You can redefine the style of various HTML elements. The style can be defined in theHTML file:

<html><head>

<style type="text/css">h2 {text-decoration:overline} h4 {text-decoration: line-through}p {text-decoration: underline} a {text-decoration: none}

</style></head><body><h2>A level 2 heading</h2><h4>A level 4 heading</h4><p>A paragraph</p><p>Another paragraph <a href="http://w3schools.com">

with a link</a></p></body>

<html>

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 16 / 27

Page 60: Basic Internet Programming

Internet Content

CSS . . .

A level 2 headingA level 4 headingA paragraphAnother paragraph with a link

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 17 / 27

Page 61: Basic Internet Programming

Internet Content

CSS . . .

Style can also be definedI in a separate CSS file indicated in a ”link” attribute in the head section of

the HTML file:<link rel="stylesheet" type="text/css" href="mystyle.css">

I or directly in the HTML code:

<p style="color: sienna; margin-left: 20px">This is a paragraph</p>

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 18 / 27

Page 62: Basic Internet Programming

Internet Content

XML

I XML is a way of describing data, according to a DTD (like SGML)

I There are no predefined XML tags (like in HTML). One has to describeones own using e.g. a DTD

I XML doesn’t do anything in itself but data from one XML document canbe presented in an indefinite number of ways

I XML can be used to exchange data, to express the configuration ofsoftware in a rich, hierarchical manner or even as program source code

I Example of an XML application: RSS (really simple syndicating). See eg.http://www.mozilla.org/products/firefox/live-bookmarks.html

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 19 / 27

Page 63: Basic Internet Programming

Internet Content

XML

I XML is a way of describing data, according to a DTD (like SGML)I There are no predefined XML tags (like in HTML). One has to describe

ones own using e.g. a DTD

I XML doesn’t do anything in itself but data from one XML document canbe presented in an indefinite number of ways

I XML can be used to exchange data, to express the configuration ofsoftware in a rich, hierarchical manner or even as program source code

I Example of an XML application: RSS (really simple syndicating). See eg.http://www.mozilla.org/products/firefox/live-bookmarks.html

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 19 / 27

Page 64: Basic Internet Programming

Internet Content

XML

I XML is a way of describing data, according to a DTD (like SGML)I There are no predefined XML tags (like in HTML). One has to describe

ones own using e.g. a DTDI XML doesn’t do anything in itself but data from one XML document can

be presented in an indefinite number of ways

I XML can be used to exchange data, to express the configuration ofsoftware in a rich, hierarchical manner or even as program source code

I Example of an XML application: RSS (really simple syndicating). See eg.http://www.mozilla.org/products/firefox/live-bookmarks.html

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 19 / 27

Page 65: Basic Internet Programming

Internet Content

XML

I XML is a way of describing data, according to a DTD (like SGML)I There are no predefined XML tags (like in HTML). One has to describe

ones own using e.g. a DTDI XML doesn’t do anything in itself but data from one XML document can

be presented in an indefinite number of waysI XML can be used to exchange data, to express the configuration of

software in a rich, hierarchical manner or even as program source code

I Example of an XML application: RSS (really simple syndicating). See eg.http://www.mozilla.org/products/firefox/live-bookmarks.html

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 19 / 27

Page 66: Basic Internet Programming

Internet Content

XML

I XML is a way of describing data, according to a DTD (like SGML)I There are no predefined XML tags (like in HTML). One has to describe

ones own using e.g. a DTDI XML doesn’t do anything in itself but data from one XML document can

be presented in an indefinite number of waysI XML can be used to exchange data, to express the configuration of

software in a rich, hierarchical manner or even as program source codeI Example of an XML application: RSS (really simple syndicating). See eg.

http://www.mozilla.org/products/firefox/live-bookmarks.html

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 19 / 27

Page 67: Basic Internet Programming

Internet Content

XML: example

<?xml version="1.0" encoding="ISO-8859-1" ?><note>

<date>2010-01-19</date><time>08:23 GMT+1</time><to>Serafim</to><from>Carina</from><heading>Reminder</heading><body>Don’t forget our lunch meeting today!</body>

</note>

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 20 / 27

Page 68: Basic Internet Programming

Internet Content

XML: example . . .

This XML-file does not appear to have any style information associated with it.The document tree is shown below.

-<note><date>2009-01-19</date><time>08:23 GMT+1</time><to>Serafim</to><from>Carina</from><heading>Reminder</heading><body>Don’t forget our lunch meeting today!</body>

</note>

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 21 / 27

Page 69: Basic Internet Programming

Internet Content

XHTML

I eXtensible HTMLI XHTML is designed to replace HTMLI XHTML 1.0 is almost identical to HTML 4.1I A stricter and cleaner version

I All tags must be closed <br> becomes <br/>. Better with <br /> as oldbrowsers understand them.

I All documents must be well-formed (<b><i>text</b></i> is illegal)I There should be no text outside tags

I XHTML is HTML defined as an XML application:http://www.w3c.org/TR/xhtml1/dtds.html

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 22 / 27

Page 70: Basic Internet Programming

Internet Content

XHTML

I eXtensible HTML

I XHTML is designed to replace HTMLI XHTML 1.0 is almost identical to HTML 4.1I A stricter and cleaner version

I All tags must be closed <br> becomes <br/>. Better with <br /> as oldbrowsers understand them.

I All documents must be well-formed (<b><i>text</b></i> is illegal)I There should be no text outside tags

I XHTML is HTML defined as an XML application:http://www.w3c.org/TR/xhtml1/dtds.html

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 22 / 27

Page 71: Basic Internet Programming

Internet Content

XHTML

I eXtensible HTMLI XHTML is designed to replace HTML

I XHTML 1.0 is almost identical to HTML 4.1I A stricter and cleaner version

I All tags must be closed <br> becomes <br/>. Better with <br /> as oldbrowsers understand them.

I All documents must be well-formed (<b><i>text</b></i> is illegal)I There should be no text outside tags

I XHTML is HTML defined as an XML application:http://www.w3c.org/TR/xhtml1/dtds.html

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 22 / 27

Page 72: Basic Internet Programming

Internet Content

XHTML

I eXtensible HTMLI XHTML is designed to replace HTMLI XHTML 1.0 is almost identical to HTML 4.1

I A stricter and cleaner versionI All tags must be closed <br> becomes <br/>. Better with <br /> as old

browsers understand them.I All documents must be well-formed (<b><i>text</b></i> is illegal)I There should be no text outside tags

I XHTML is HTML defined as an XML application:http://www.w3c.org/TR/xhtml1/dtds.html

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 22 / 27

Page 73: Basic Internet Programming

Internet Content

XHTML

I eXtensible HTMLI XHTML is designed to replace HTMLI XHTML 1.0 is almost identical to HTML 4.1I A stricter and cleaner version

I All tags must be closed <br> becomes <br/>. Better with <br /> as oldbrowsers understand them.

I All documents must be well-formed (<b><i>text</b></i> is illegal)I There should be no text outside tags

I XHTML is HTML defined as an XML application:http://www.w3c.org/TR/xhtml1/dtds.html

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 22 / 27

Page 74: Basic Internet Programming

Internet Content

XHTML

I eXtensible HTMLI XHTML is designed to replace HTMLI XHTML 1.0 is almost identical to HTML 4.1I A stricter and cleaner version

I All tags must be closed <br> becomes <br/>. Better with <br /> as oldbrowsers understand them.

I All documents must be well-formed (<b><i>text</b></i> is illegal)I There should be no text outside tags

I XHTML is HTML defined as an XML application:http://www.w3c.org/TR/xhtml1/dtds.html

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 22 / 27

Page 75: Basic Internet Programming

Internet Content

MIME: Multimedia Internet Mail Extension

I An open standard describing how multimedia is sent via email (initially)HTTP request, response, etc

I Describes how the parts of the content are organized. A part can containother parts, . . .Globally/parts/subparts/. . .

I Describes a type for the data sent, for exampleI text

I plain, htmlI newsI postscript, pdf, docI zipI image

I jpeg, tiff, gif, . . .I audioI video

I mpeg, quicktime, wmv . . .

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 23 / 27

Page 76: Basic Internet Programming

Internet Content

MIME: Multimedia Internet Mail Extension

I An open standard describing how multimedia is sent via email (initially)HTTP request, response, etc

I Describes how the parts of the content are organized. A part can containother parts, . . .Globally/parts/subparts/. . .

I Describes a type for the data sent, for exampleI text

I plain, htmlI newsI postscript, pdf, docI zipI image

I jpeg, tiff, gif, . . .I audioI video

I mpeg, quicktime, wmv . . .

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 23 / 27

Page 77: Basic Internet Programming

Internet Content

MIME: Multimedia Internet Mail Extension

I An open standard describing how multimedia is sent via email (initially)HTTP request, response, etc

I Describes how the parts of the content are organized. A part can containother parts, . . .Globally/parts/subparts/. . .

I Describes a type for the data sent, for exampleI text

I plain, htmlI newsI postscript, pdf, docI zipI image

I jpeg, tiff, gif, . . .I audioI video

I mpeg, quicktime, wmv . . .

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 23 / 27

Page 78: Basic Internet Programming

Internet Content

MIME: Multimedia Internet Mail Extension

I An open standard describing how multimedia is sent via email (initially)HTTP request, response, etc

I Describes how the parts of the content are organized. A part can containother parts, . . .Globally/parts/subparts/. . .

I Describes a type for the data sent, for exampleI text

I plain, htmlI newsI postscript, pdf, docI zipI image

I jpeg, tiff, gif, . . .I audioI video

I mpeg, quicktime, wmv . . .

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 23 / 27

Page 79: Basic Internet Programming

Internet Content

HTTP: HyperText Transport Protocol

I Standard that describes how a web client (mostly a browser) and servercommunicate to exchange data

I Uses MIME to encode data both from the browser to the server (request)and back (response)

I Uses TCP/IP for data transferI To get the /utbildning/kth/kurser/DD1335/gruint09/index.html

page the client sends a request, like GET

/utbildning/kth/kurser/DD1335/gruint09/index.html HTTP/1.1

I See http://www.w3c.org/Protocols

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 24 / 27

Page 80: Basic Internet Programming

Internet Content

HTTP: HyperText Transport Protocol

I Standard that describes how a web client (mostly a browser) and servercommunicate to exchange data

I Uses MIME to encode data both from the browser to the server (request)and back (response)

I Uses TCP/IP for data transferI To get the /utbildning/kth/kurser/DD1335/gruint09/index.html

page the client sends a request, like GET

/utbildning/kth/kurser/DD1335/gruint09/index.html HTTP/1.1

I See http://www.w3c.org/Protocols

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 24 / 27

Page 81: Basic Internet Programming

Internet Content

HTTP: HyperText Transport Protocol

I Standard that describes how a web client (mostly a browser) and servercommunicate to exchange data

I Uses MIME to encode data both from the browser to the server (request)and back (response)

I Uses TCP/IP for data transfer

I To get the /utbildning/kth/kurser/DD1335/gruint09/index.html

page the client sends a request, like GET

/utbildning/kth/kurser/DD1335/gruint09/index.html HTTP/1.1

I See http://www.w3c.org/Protocols

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 24 / 27

Page 82: Basic Internet Programming

Internet Content

HTTP: HyperText Transport Protocol

I Standard that describes how a web client (mostly a browser) and servercommunicate to exchange data

I Uses MIME to encode data both from the browser to the server (request)and back (response)

I Uses TCP/IP for data transferI To get the /utbildning/kth/kurser/DD1335/gruint09/index.html

page the client sends a request, like GET

/utbildning/kth/kurser/DD1335/gruint09/index.html HTTP/1.1

I See http://www.w3c.org/Protocols

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 24 / 27

Page 83: Basic Internet Programming

Internet Content

HTTP: HyperText Transport Protocol

I Standard that describes how a web client (mostly a browser) and servercommunicate to exchange data

I Uses MIME to encode data both from the browser to the server (request)and back (response)

I Uses TCP/IP for data transferI To get the /utbildning/kth/kurser/DD1335/gruint09/index.html

page the client sends a request, like GET

/utbildning/kth/kurser/DD1335/gruint09/index.html HTTP/1.1

I See http://www.w3c.org/Protocols

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 24 / 27

Page 84: Basic Internet Programming

Internet Content

HTTP, request

I Command (GET or POST)GET /utbildning/kth/kurser/DD1335/index.php HTTP/1.1

I Headers (name:value pairs )Host: www.csc.kth.se

Accept: */* accept any MIME typeI empty lineI Content (in the declared content-type, nothing in the case of GET)I If it is a POST request, content is sent too

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 25 / 27

Page 85: Basic Internet Programming

Internet Content

HTTP, request

I Command (GET or POST)GET /utbildning/kth/kurser/DD1335/index.php HTTP/1.1

I Headers (name:value pairs )Host: www.csc.kth.se

Accept: */* accept any MIME type

I empty lineI Content (in the declared content-type, nothing in the case of GET)I If it is a POST request, content is sent too

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 25 / 27

Page 86: Basic Internet Programming

Internet Content

HTTP, request

I Command (GET or POST)GET /utbildning/kth/kurser/DD1335/index.php HTTP/1.1

I Headers (name:value pairs )Host: www.csc.kth.se

Accept: */* accept any MIME typeI empty line

I Content (in the declared content-type, nothing in the case of GET)I If it is a POST request, content is sent too

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 25 / 27

Page 87: Basic Internet Programming

Internet Content

HTTP, request

I Command (GET or POST)GET /utbildning/kth/kurser/DD1335/index.php HTTP/1.1

I Headers (name:value pairs )Host: www.csc.kth.se

Accept: */* accept any MIME typeI empty lineI Content (in the declared content-type, nothing in the case of GET)

I If it is a POST request, content is sent too

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 25 / 27

Page 88: Basic Internet Programming

Internet Content

HTTP, request

I Command (GET or POST)GET /utbildning/kth/kurser/DD1335/index.php HTTP/1.1

I Headers (name:value pairs )Host: www.csc.kth.se

Accept: */* accept any MIME typeI empty lineI Content (in the declared content-type, nothing in the case of GET)I If it is a POST request, content is sent too

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 25 / 27

Page 89: Basic Internet Programming

Internet Content

HTTP, response

I Command (mostly OK)HTTP/1.1 200 OK

I Headers (for example content-type, MIME)Date: Fri, 12 Jan 2009 00:11:31 GMT

Server: Apache/2.2.3 (Fedora) PHP/5.1.6

mod_perl/2.0.1 mod_ssl/2.0.54 OpenSSL/0.9.8b

Transfer-Encoding: chunked

Content-type: text/html

I empty lineI content (in in our case the file

/public/www-csc/utbildning/kth/kurser/DD1335/index.php

at CSC)

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 26 / 27

Page 90: Basic Internet Programming

Internet Content

HTTP, response

I Command (mostly OK)HTTP/1.1 200 OK

I Headers (for example content-type, MIME)Date: Fri, 12 Jan 2009 00:11:31 GMT

Server: Apache/2.2.3 (Fedora) PHP/5.1.6

mod_perl/2.0.1 mod_ssl/2.0.54 OpenSSL/0.9.8b

Transfer-Encoding: chunked

Content-type: text/html

I empty lineI content (in in our case the file

/public/www-csc/utbildning/kth/kurser/DD1335/index.php

at CSC)

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 26 / 27

Page 91: Basic Internet Programming

Internet Content

HTTP, response

I Command (mostly OK)HTTP/1.1 200 OK

I Headers (for example content-type, MIME)Date: Fri, 12 Jan 2009 00:11:31 GMT

Server: Apache/2.2.3 (Fedora) PHP/5.1.6

mod_perl/2.0.1 mod_ssl/2.0.54 OpenSSL/0.9.8b

Transfer-Encoding: chunked

Content-type: text/html

I empty line

I content (in in our case the file/public/www-csc/utbildning/kth/kurser/DD1335/index.php

at CSC)

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 26 / 27

Page 92: Basic Internet Programming

Internet Content

HTTP, response

I Command (mostly OK)HTTP/1.1 200 OK

I Headers (for example content-type, MIME)Date: Fri, 12 Jan 2009 00:11:31 GMT

Server: Apache/2.2.3 (Fedora) PHP/5.1.6

mod_perl/2.0.1 mod_ssl/2.0.54 OpenSSL/0.9.8b

Transfer-Encoding: chunked

Content-type: text/html

I empty lineI content (in in our case the file

/public/www-csc/utbildning/kth/kurser/DD1335/index.php

at CSC)

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 26 / 27

Page 93: Basic Internet Programming

Internet Content

HTTP, proxies

I Some organizations wish to limit the HTTP accesses from their networkto other networks

I To do that, all browsers will have to connect to a proxy running on a hostinside the local network. Other connections are restricted by a firewall

I The proxy ’looks’ like a normal HTTP server, but it doesn’t actually hostany page. It is not limited by the firewall

I The proxy will connect to the desired host on the InternetI The proxy can decide to block connetion to some ’banned’ hostI The proxy can also do caching: if a page is requested by a lot of people in

the local network, it will be served fasterI The proxy adds special headers to the HTTP responseI Some networks only require proxy for port 80. Links to http://host:8080

may still workI Proxies can be defined for many other protocols

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 27 / 27

Page 94: Basic Internet Programming

Internet Content

HTTP, proxies

I Some organizations wish to limit the HTTP accesses from their networkto other networks

I To do that, all browsers will have to connect to a proxy running on a hostinside the local network. Other connections are restricted by a firewall

I The proxy ’looks’ like a normal HTTP server, but it doesn’t actually hostany page. It is not limited by the firewall

I The proxy will connect to the desired host on the InternetI The proxy can decide to block connetion to some ’banned’ hostI The proxy can also do caching: if a page is requested by a lot of people in

the local network, it will be served fasterI The proxy adds special headers to the HTTP responseI Some networks only require proxy for port 80. Links to http://host:8080

may still workI Proxies can be defined for many other protocols

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 27 / 27

Page 95: Basic Internet Programming

Internet Content

HTTP, proxies

I Some organizations wish to limit the HTTP accesses from their networkto other networks

I To do that, all browsers will have to connect to a proxy running on a hostinside the local network. Other connections are restricted by a firewall

I The proxy ’looks’ like a normal HTTP server, but it doesn’t actually hostany page. It is not limited by the firewall

I The proxy will connect to the desired host on the InternetI The proxy can decide to block connetion to some ’banned’ hostI The proxy can also do caching: if a page is requested by a lot of people in

the local network, it will be served fasterI The proxy adds special headers to the HTTP responseI Some networks only require proxy for port 80. Links to http://host:8080

may still workI Proxies can be defined for many other protocols

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 27 / 27

Page 96: Basic Internet Programming

Internet Content

HTTP, proxies

I Some organizations wish to limit the HTTP accesses from their networkto other networks

I To do that, all browsers will have to connect to a proxy running on a hostinside the local network. Other connections are restricted by a firewall

I The proxy ’looks’ like a normal HTTP server, but it doesn’t actually hostany page. It is not limited by the firewall

I The proxy will connect to the desired host on the Internet

I The proxy can decide to block connetion to some ’banned’ hostI The proxy can also do caching: if a page is requested by a lot of people in

the local network, it will be served fasterI The proxy adds special headers to the HTTP responseI Some networks only require proxy for port 80. Links to http://host:8080

may still workI Proxies can be defined for many other protocols

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 27 / 27

Page 97: Basic Internet Programming

Internet Content

HTTP, proxies

I Some organizations wish to limit the HTTP accesses from their networkto other networks

I To do that, all browsers will have to connect to a proxy running on a hostinside the local network. Other connections are restricted by a firewall

I The proxy ’looks’ like a normal HTTP server, but it doesn’t actually hostany page. It is not limited by the firewall

I The proxy will connect to the desired host on the InternetI The proxy can decide to block connetion to some ’banned’ host

I The proxy can also do caching: if a page is requested by a lot of people inthe local network, it will be served faster

I The proxy adds special headers to the HTTP responseI Some networks only require proxy for port 80. Links to http://host:8080

may still workI Proxies can be defined for many other protocols

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 27 / 27

Page 98: Basic Internet Programming

Internet Content

HTTP, proxies

I Some organizations wish to limit the HTTP accesses from their networkto other networks

I To do that, all browsers will have to connect to a proxy running on a hostinside the local network. Other connections are restricted by a firewall

I The proxy ’looks’ like a normal HTTP server, but it doesn’t actually hostany page. It is not limited by the firewall

I The proxy will connect to the desired host on the InternetI The proxy can decide to block connetion to some ’banned’ hostI The proxy can also do caching: if a page is requested by a lot of people in

the local network, it will be served faster

I The proxy adds special headers to the HTTP responseI Some networks only require proxy for port 80. Links to http://host:8080

may still workI Proxies can be defined for many other protocols

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 27 / 27

Page 99: Basic Internet Programming

Internet Content

HTTP, proxies

I Some organizations wish to limit the HTTP accesses from their networkto other networks

I To do that, all browsers will have to connect to a proxy running on a hostinside the local network. Other connections are restricted by a firewall

I The proxy ’looks’ like a normal HTTP server, but it doesn’t actually hostany page. It is not limited by the firewall

I The proxy will connect to the desired host on the InternetI The proxy can decide to block connetion to some ’banned’ hostI The proxy can also do caching: if a page is requested by a lot of people in

the local network, it will be served fasterI The proxy adds special headers to the HTTP response

I Some networks only require proxy for port 80. Links to http://host:8080may still work

I Proxies can be defined for many other protocols

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 27 / 27

Page 100: Basic Internet Programming

Internet Content

HTTP, proxies

I Some organizations wish to limit the HTTP accesses from their networkto other networks

I To do that, all browsers will have to connect to a proxy running on a hostinside the local network. Other connections are restricted by a firewall

I The proxy ’looks’ like a normal HTTP server, but it doesn’t actually hostany page. It is not limited by the firewall

I The proxy will connect to the desired host on the InternetI The proxy can decide to block connetion to some ’banned’ hostI The proxy can also do caching: if a page is requested by a lot of people in

the local network, it will be served fasterI The proxy adds special headers to the HTTP responseI Some networks only require proxy for port 80. Links to http://host:8080

may still work

I Proxies can be defined for many other protocols

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 27 / 27

Page 101: Basic Internet Programming

Internet Content

HTTP, proxies

I Some organizations wish to limit the HTTP accesses from their networkto other networks

I To do that, all browsers will have to connect to a proxy running on a hostinside the local network. Other connections are restricted by a firewall

I The proxy ’looks’ like a normal HTTP server, but it doesn’t actually hostany page. It is not limited by the firewall

I The proxy will connect to the desired host on the InternetI The proxy can decide to block connetion to some ’banned’ hostI The proxy can also do caching: if a page is requested by a lot of people in

the local network, it will be served fasterI The proxy adds special headers to the HTTP responseI Some networks only require proxy for port 80. Links to http://host:8080

may still workI Proxies can be defined for many other protocols

DD1335 (Lecture 2) Basic Internet Programming Spring 2010 27 / 27