This assignment makes use of the files contained in this zip file. This assignment is due Friday, April 26.
This assignment is based on the server framework and the example servers in httpServer.zip.
In the zip file there is a file Hw4.java
that outlines how to implement a web application using the server framework we used in class. The Hw4
class extends the HttpMethodsAdaptor
class from the framework. You need to override two of the HTTP method handlers, doGet()
and doPost()
.
In the zip file there is a demo version of the web app implemented as a jar file. Run the demo version, then open a browser and navigate to this local URL.
You should see the main page of the application. Use the two HTML forms in that page to use the application.
Turn in a zip file called CS336Hw4Surname.zip
(where Surname
is your last name) containing your version of Hw4.java
.
As part of your implementation of Hw4.java
you need to generate the HTML code that displays the downloaded photograph. You need to run the demo program and use your browser's "View page source" feature to see what that HTML looks like. Then you need to build that HTML as a Java string in your Hw4.java
code. You will need to imbed the photograph's URL into your HTML string. You get the photograph's URL from the local file photo-urls.txt
which is in the zip file. Each line of that file is exactly one URL. The HTTP request object has the query string with the number of the photo that you need to load. Parse that string parameter into an integer, then read that many lines from the photo-urls.txt
file, but only keep the last line you read. The last line you read is the URL that you need. Imbed that URL into an HTML img
tag imbedded in your web page's HTML. (Be sure to look at how the demo program does this.)
This assignment is due Friday, April 26.