![]() |
CS 455/555 - Intro to Networks and Communications
Fall 2008: Tues/Thurs 3-4:15pm, Dragas 1117 |
Syllabus (pdf) |
Program 1: URL ParserAssigned: Thursday, August 28, 2008
DescriptionDuring the semester, we will be building up to writing a text-based web client that can request and download a single file from a web server using HTTP, which is the protocol used by two computers to exchange information on the web. This first assignment will not involve any networking or socket programming, but will just get you started on the way to building an HTTP client in Java on the CS Unix systems. Note: Do not wait until the last minute to start this assignment. If you are inexperienced with Java or Unix, please look at the tutorials posted on the course webpage and ask questions early. BackgroundYour program will take a URL as its only command-line argument. The URL will be given in the following format: hostname - the web server's hostname :port - an optional command that tells the web client to connect to a different port than the default of port 80 (we'll talk more about how this is used later on) path - the path from the web server's main directory to the requested file, if this is not present, then the path is '/' URL Examples:
The hostname is shown in bold font, and everything after the first '/' following the hostname is part of the path. Requirements
Rules
TestingYour program will be graded on how well it satisfies the requirements in handling a set of test URLs. You should test your program rigorously with various URLs before submitting. Example 1 % java UrlParser http://www.cs.odu.edu/~mweigle/foo.txt URL : http://www.cs.odu.edu/~mweigle/foo.txt Host: www.cs.odu.edu Port: 80 Path: /~mweigle/foo.txt Example 2 % java UrlParser http://www.amazon.com:4567/Harry_Potter/this/is/a/book.html URL : http://www.amazon.com:4567/Harry_Potter/this/is/a/book.html Host: www.amazon.com Port: 4567 Path: /Harry_Potter/this/is/a/book.html Example 3 % java UrlParser http://www.amazon.com URL : http://www.amazon.com Host: www.amazon.com Port: 80 Path: / Example 4 % java UrlParser http://www.amazon.com/ URL : http://www.amazon.com/ Host: www.amazon.com Port: 80 Path: / Example 5 % java UrlParser Usage: java UrlParser URL SubmissionYou must name your source file UrlParser.java. Make sure that you submit all files necessary to compile your program. But, do not submit compiled files (.class files). Directions for submitting your assignment through Blackboard Getting Started with JavaIf you've never programmed with Java before, here are a couple of helpful hints:
Here is the skeleton for Program 1 (to be saved as UrlParser.java): // Insert Your Name // Insert Your Class (CS 455 or CS 555), Fall 2008 // Program 1 - URL Parser import java.io.*; class UrlParser { public static void main (String argv[]) { // insert your code here } } |