HTML and HTTP

Basic HTML

Example

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Draft//EN">
<html> <head>
<title>HTML and HTTP</title>
</head>

<body>
<center>
<h1>HTML and HTTP</h1>
</center>

<h2>Basic HTML</h2>

<ul>
  <li>
      HTML is a markup language defined in SGML (Standard Generalised
      Markup Language)
  <li> Markup is by tags <br>
      <tag>content</tag>
</ul>
</body>
</html>

Versions

Frames

Example Frame

<frameset cols="30%,70%">
  <frame src="index_list.html" name=list>
  <frame src="new.html" name="contents">

  <noframes>
    <a href="index_list.html"> Index of Systems Software pages </a>
  </noframes>

</frameset>                    

Frame navigation

Complex frameset example

See http://pandonia.canberra.edu.au/ssw/

index.html

<html> <head>
<frameset cols="30%,70%">
  <frame src="index_list.html" name=list>
  <frame src="new.html" name="contents">

  <noframes>
    <a href="index_list.html"> Index of Systems Software pages </a>
  </noframes>

</frameset>

index_list.html

<a href="new.html" target="contents">
What's new
</a>

<a href="unix.html" target="_parent">
Unix API
</a>

unix.html

<frameset cols="30%,70%">
  <frame src="unix_list.html" name=list>
  <frame src="unix_overview.html" name="contents">

  <noframes>
    <a href="unix_list.html"> Unix API pages </a>
  </noframes>
</frameset>

unix_list.html


<a href="unix_overview.html" target="contents">
Overview
</a><br>
<a href="utilities/unix.html" target="contents">
Utilities
</a><br>

<a href="index.html" target="_parent">
Systems Software Home
</a>

Forms

Form example

<form action="http://pandonia/cgi-script" method="post">
<label>
  First name
  <input type="text" name="firstname">
</label>
<label>
  Last name
  <input type="text" name="lastname">
</label>
</form>  

Browser Support

XHTML

Simple differences between XHTML and HTML

Sample XHTML document

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
          "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Virtual Library</title>
</head>
<body>
<p>Moved to <a href="http://vlib.org/">vlib.org</a>.</p>
</body>
</html>

HTTPD

Information from browser

Response format

Status codes

Status-Code =     "200" ; OK
                | "201" ; Created
                | "202" ; Accepted
                | "204" ; No Content
                | "301" ; Moved permanently
                | "302" ; Moved temporarily
                | "304" ; Not modified
                | "400" ; Bad request
                | "401" ; Unauthorised
                | "403" ; Forbidden
                | "404" ; Not found
                | "500" ; Internal server error
                | "501" ; Not implemented
                | "502" ; Bad gateway
                | "503" | Service unavailable
                | extension-code

Dates

Echo server

Test what browsers send to servers using this "echo server"

import java.net.*;
import java.io.*;

public class EchoServer {

	final static protected int PORT = 8000;

 	public static void main(String[] argv) {
		try {
			new EchoServer();
		} catch(IOException e) {
			e.printStackTrace();
		}
	}

	public EchoServer() throws IOException {
		ServerSocket server = new ServerSocket(PORT);
		Socket socket = server.accept();

		InputStream is = socket.getInputStream();
		OutputStream os = socket.getOutputStream();
		DataOutputStream out = new DataOutputStream(os);
		DataInputStream in = new DataInputStream(is);

		out.writeBytes("HTTP/1.1 404 OK\n");
		out.writeBytes("Content-Type: text/plain\n\n");

		String line;
		while ((line = in.readLine()) != null &&
			(line.length() != 0)) {
			out.writeBytes(line + "\n");
		}
		out.close();
		socket.close();
	}
}

Echo client

Identifying the browser

Exercises

  1. Edit documents using raw HTML, to ensure you know what the HTML tags are and how to use them
  2. Build some documents using frames
  3. View documents using a variety of browsers. Note carefully the differences between each
  4. Examine the HTTP requests from different browsers
  5. Write a server program to identify different browsers
  6. Find statistics on the popularity of different browsers
  7. Find an HTML "syntax checker" (HTML validator) and use it to check the validity of various HTML pages
  8. Do some experiments to determine which browsers support XHTML?
  9. Write a date parser to handle the three allowable formats, and won't crash on other formats
  10. Write a browser detection algorithm, and test it on lots of browsers

Jan Newmarch (http://pandonia.canberra.edu.au)
jan@ise.canberra.edu.au
Last modified: Tue Jul 25 14:37:46 EST 2000
Copyright ©Jan Newmarch