Computer Science 2B

Practical Assignment 3 16 August 2011 Time: Deadline — 2011-08-16 16h30 Marks: 30

Practical assignments must be uploaded to before the end of your session on 2011-08-16 (please check EVE for your respective session). Remember to SUBMIT your work during your session otherwise you will get 0. In this practical, you will create custom web server (that can also be accessed by your browser of choice) and a very basic custom web browser (that has basic Navigation capabilities).


Web Server

Your web server should therefore be able to understand the commands sent by a typical web browser and it needs to return the requested document or display an error message correctly. Vendors use the RFC 2616 document on the HTTP protocol to develop web browsers that are compatible with HTTP/1.1 (but you can Google it to get the full specification). Your Web Server must be able to serve any web page that is stored in the directory where the server runs from. You can use your own html pages to demonstrate that it works correctly. If you type in your respective browser, it should display the MyPage.html document. The web server should wait on port 80 and like many other web servers it should be able to do the following: • If a loop back is entered ( or localhost) the default document is served (index.html). • If the specified document exists, it should be served to the browser. • If the web server cannot find the document, it should serve an error page which informs the user that the page does not exist. • The web server should be able to serve more than one request (use a endless loop that checks for incoming requests).

Page 1 of 2

(c) Displays an error if page could not be found.0. it renders the HTML retrieved from the web server. you learnt how to retrieve HTML pages from a web server and save it locally. (b) JEditorPane navigates to the URL specified and renders the retrieved HTML.0. [5] [5] [5] [5] [3] [4] [3] Page 2 of 2 . the URL from the textfield is used to set the JEditorPane page and renders the HTML document retrieved from the URL. a JButton to confirm input (GO button) and a JEditorPane to display the retrieved HTML. (a) Default HTML document served to the browser (with http://127. Marksheet 1.0 200 OK\r\n Content-Type: text/html\rn\n\r\n" 2 Web Browser Your web browser should then be able to issue requests and render the respective pages returned from the web server. but instead of saving it to file. You do not have to implement additional link navigation within the page itself! • If the JEditorPane throws an Exception. 2. (a) Web Browser has a JTextField for the URL. In our case we simply render the HTML using the JEditorPane in Java.Computer Science 2B Practical Assignment 3 16 August 2011 Please remember to send the correct headers to the browser. we perform the following: • Create a JFrame that contains a JTextfield for URL input. For HTML the header should look like: "HTTP/1. • When a user enters the URL in the textfield and clicks the GO button. From your first practical. (d) HTML documents are not hard-coded in the source code but are retrieved from real HTML files. (c) Serves a “Page not found” if the document specified does not exist. so that it knows what type of information will be expected. A browser performs a similar task.1) (b) Serves any other HTML document that exists that is local to the server. Please note. a message dialog should be shown to the user to indicate that the page could not be found. In order to achieve this. JButton for the GO Button and a JEditorPane for rendering the HTML.

Sign up to vote on this title
UsefulNot useful