Skip to main content

You are here: Teaching, Distributed Systems, Week 3

This week's topic is Build your own Web Server.


Internal Page Navigation Links


Learning Outcomes

Upon completion of this week's class and tasks, you should be able to do the following:

  1. Use HTTP as an example of a request-reply protocol, to demonstrate the requirements for interprocess communication across the network.
  2. Distinguish between HTTP/1.0 and HTTP/1.1.
  3. Develop simple client-server based applications using TCP.
  4. Use the HTTP APIs for Java to build web clients.
  5. Demonstrate an understanding of how to build a web server using the Java APIs.

Return to the internal page navigation links


Notes and Handouts

Return to the internal page navigation links


Tasks

Task NumberDetails
1Download the code for today's class.
2

Run the EchoClient and EchoServer applications as follows (as separate processes):

java EchoServer 12345

java EchoClient localhost 12345 "Welcome to the House of Fun"
					
3

Run the UserAgent program as follows:

java UserAgent http://www.irishtimes.com/ it.html
					

Note how the content of the Irish Times homepage is downloaded and copied into the local file, it.html. Open it.html, but note that since it doesn't download the stylesheets or the images, the file will not render nicely in the browser.

4

Run the WebServer program as follows:

java WebServer
					

This web server will run of port 8080.

Put a HTML file in the same folder as you are running your process, calling it, say, my_file.html.

If you then direct your browser to the following URL, you will be able to access your file:

http://localhost:8080/my_file.html
					
5Use the UserAgent program to access a file on your web server.
6Augment your web server so that it implements the 100 Continue response, simulating slow response times by using Java's Thread.sleep method.
7Implement chunked transfer encoding on your web server.

Return to the internal page navigation links


Further Reading

Return to the internal page navigation links