Homework assignment: Enhancing the web server. (10%)
Due: Before the class of Monday, Apr. 2. Email me your solution.
Part 1. Web server (7%)
The
web server project contains two
programs, server0 and server1.
The purpose of server0 is to help understand the format and content of
the data sent from a web browser to the server. (The full specification
for HTTP 1.1 can be found here.)
The program server1 has been evolved towards a more functional web
server.
As we have discussed and seen in the class, there are a few problems
with server1.
1. Improper exception handling.
When a non-existent resource is requested, the server will throw an
exception. Consequently, the browser will hang.
A better response would be to send the browser a message stating
explicitly that the requested resource is not on the server.
2. Lack of parallelism.
The current server1 processes browser requests one at a time. It cannot
accept a new request unless the current one is completely served. This
is inefficient.
A more efficient way is for the server to use Java threading API to
create a thread for each request. This thread will then respond
according to the content of the request that it handles.
In this way, the main program is freed to accept a new request.
For this assignment, you are going to implement a solution for at least one of the above problems.
Your code should be tested, commented, and work correctly.
There are probably other drawbacks in the code, and you are welcome to
fix them as well. Be sure to write a short note about the drawbacks and
how you have fixed them.
Part 2. Web technologies (3%)
It is assumed that you have started the Tomcat server on your laptop.
Type in your browser http://localhost:8080/examples/servlets/, you will
see a list of servlet examples provided by Tomcat.
Your task is to completely
remove the session example from the server (the last one in the list).
This means that after completing the task, you should see neither the
link for the session servlet at
http://localhost:8080/examples/servlets/,
nor the session screen when
http://localhost:8080/examples/servlets/servlet/SessionExample is typed
in the browser.
Zip up the $TOMCAT_DIR/webapps/examples
directory and send it to me.