CMSC 433 - Project 2 - Java exercise - Due Feb 28th

Write an toy version of a http server. It should accept requests of the form:

http://marlowe:33101/Foobar/MyTest

A web browser will turn a URL request like that into a web server request like:

GET /Foobar/MyTest HTTP/1.0

In response to this, the server should create an instance r of the class Foobar, invoke r.setArg("MyTest"), invoke r.setOutputStream(...) with the output stream for the http request, and then invoke new Thread(r).start().

Alternatively, if you want to do a slightly simplier version of the project, just invoke r.run() rather than creating a thread. If you don't create threads, you don't have to worry about synchronization. If you do the non-threaded version of the project, there is a 10 point deduction (bugs in your use of threads could cost you more than 10 points).

The port your server should be taken from the command line. To avoid conflicts, when testing you should use a port number calculated from your account number as port 331xx, where xx is your account number. For example, if your account is wp43317, listen to port 33117.

The server objects which can be used must all implement the interface:

public interface MiniServlet extends Runnable {
    void setArg(String arg);
    void setOutputStream(java.io.OutputStream out);
    }

The servlets should be loaded dynamically (using Class.forName(...)).

I've provided you with some classes:

Note that we will test your MiniServlets using our web server, and your webserver using our MiniServlets.

You also need to write some servlets:

I've made my server available on port 33101 of savoir.cs.umd.edu. Here are some sample queries:

Note: Raw proxy shows you the http headers returned by a request. You don't have to implement RawProxy.

Web Accessibility