EE-WBC Assignment 4

Program 1 (30pts.)

Complete the provided test program that reads the location of a Web site as a string and calls a function that splits it into protocol name, port number, server name, and file name that starts with /. The program checks if the given Web site location was provided as a command line argument. If so, it uses it (add code). If not, it asks the user to enter it (already provided). The program calls a function called UrlSplitter that returns a variable of type Locator. (Class Locator) is already provided.) Your main task is to implement that function.

The complete location has the format of protocol://server:port/file/name/with.folder, for example http://gdansk.bradley.edu:80/olekmali/index.html. However, not all parts of it are always present. If protocol:// is omited please assume "http", if :port is omited, please assume 80 for "http" and 21 for "ftp". (Ideally you could get default values for other protocls as well.) Assume the Web server name is always there. If there is no filename, assume "/". Please note that in case the filename is not provided they may or may not be "/" present after the server name.

Here are examples of inputs and outputs that may be used to test your program:

Input Stringprotocolportserverfile
http://gdansk.bradley.edu:80/olemali/index.htmlhttp80gdansk.bradley.edu/olekmali/index.html
gdansk.bradley.edu/olekmali/index.htmlhttp80gdansk.bradley.edu/olekmali/index.html
gdansk.bradley.edu/olekmali/index.htmlhttp80gdansk.bradley.edu/olekmali/index.html
http://cegt201.bradley.edu/http80cegt201.bradley.edu/
http://cegt201.bradley.eduhttp80cegt201.bradley.edu/
http://cegt201.bradley.edu:88http88cegt201.bradley.edu/
cegt201.bradley.eduhttp80cegt201.bradley.edu/
ftp://cegt201.bradley.eduftp21cegt201.bradley.edu/
e.t.c.

Please send the source code only for the complete program as a file attachment with proper name. Source code pasted into the body of an email will not be graded. The program must compile to get any credit

Hint: you may do elaborate but straightforward work with String class or look up and study another class in the extensive Java library, and complete the function almost in one line. (three letter name that starts with letter 'U'.)

Homework Submission

Attach all source code in files with proper names and extensions (*.html, *.java, *.pl, *.php, .htaccess e.t.c.). Do not ZIP files together or include compiled files (e.g. *.class). In case of dynamic Web pages (JavaScript or CGI) or Java applets also send the complete URL (including http://) that points to a page on your Web site that demonstrates your homework. Send your homework via e- mail to the instructor at olekmali at bradley dot edu. Please set the message subject to: web-hw4.

Thank you.

web site front local main page local list page print this page   general bookmarks software bookmarks go back close this page copyright info   visitor counter