CS 455/555 - Intro to Networks and Communications
Fall 2009: Tues/Thurs 3-4:15pm, Spong 0108

Print - Admin

Announcements

Staff

  • Dr. Michele Weigle
  • mweigle at cs.odu.edu
  • E&CS 3214
  • Office Hours: MW 2:30-4pm
  • Grader: Hui Shi
  • hshi at cs.odu.edu

Schedule

Syllabus (pdf)

Useful Links

Program 1b: URL Parser

Assigned: Thursday, September 17, 2009
Due: Thursday, September 24, 2009 before class (No late assignments will be accepted)

Background Requirements Rules Testing Submission

Background

Your program will take a URL as its only command-line argument. The URL will be given in the following format:
http://hostname[:port][/path]

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

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:

http://www.cs.odu.edu/~mweigle/CS455-F08

http://www.fakehost.com:765/fakepath/fakefile.html

The hostname is shown in bold font, and everything after (and including) the first '/' following the hostname is part of the path.

Requirements

  • Take a URL as the only command-line argument. If given no command-line argument, print a "Usage" statement and exit.
  • If the URL does not start with "http://", print an error message and exit.
  • Separately print the URL, hostname, port (80, if no alternate port is given), and path provided in the URL (/, if no path given).
  • Your program should not crash (or throw an Exception), no matter the input given to it.
  • You may not use the java.net.URL classes to parse the URL.

Rules

  • As with all projects, you are not permitted to work with anyone else (even students not in the class) - all of the coding and documentation must be your own.
  • Your program must compile and run on the CS Unix machines.
    • Once you've uploaded your program to Blackboard, double-check what Blackboard has (download and compile the submission) and let me know if it's different than what you submitted.

Testing

Your 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. Because your programs will be run and tested using a script, you must format your output exactly as I have described or you will lose points.

Example 1

% java UrlParser http://www.cs.odu.edu/~mweigle/files/foo.txt

http://www.cs.odu.edu/~mweigle/files/foo.txt 
www.cs.odu.edu 
80 
/~mweigle/files/foo.txt

Example 2

% java UrlParser http://www.amazon.com:4567/Harry_Potter/this/is/a/book.html

http://www.amazon.com:4567/Harry_Potter/this/is/a/book.html 
www.amazon.com 
4567 
/Harry_Potter/this/is/a/book.html

Example 3

% java UrlParser http://www.amazon.com 

http://www.amazon.com 
www.amazon.com 
80 
/

Example 4

% java UrlParser http://www.amazon.com/ 

http://www.amazon.com/ 
www.amazon.com 
80 
/

Example 5

% java UrlParser

Usage: java UrlParser URL

Example 6

% java UrlParser amazon.com

Error: improper URL format

Submission

You 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