CSc 2310 Principles of Computer Programming I
Spring 1999
Programming Assignment #5
Due: 5 April 1999 (Monday)

  1. Write a Java program, called WebURL.java, which prompts the user for a URL. The program should print all the URLs mentioned in the Web page corresponding to the URL the user entered. A sample run of the program is shown below:
    A:> java WebURL
    Enter URL: http://tinman.cs.gsu.edu
    
    The URLs mentioned in the Web page http://tinman.cs.gsu.edu are:
    
    http://www.cs.gsu.edu
    http://www.gsu.edu/
    http://www.accessatlanta.com/
    http://www.peachnet.edu/guide/
    http://wings.buffalo.edu/world/usa.html
    http://tinman.cs.gsu.edu/~raj/oradoc
    http://tinman.cs.gsu.edu:9001/ows-doc/index.htm
    http://java.sun.com/products/jdbc/html-0120/packages.html
    http://tinman.cs.gsu.edu/~raj/msqldoc/manual.html
    http://tinman.cs.gsu.edu/~raj/sqljdoc/ug.htm
    http://tinman.cs.gsu.edu/~raj/osjidoc
    http://tinman.cs.gsu.edu/~raj/osidoc/manual.html
    http://tinman.cs.gsu.edu/~raj
    http://tinman.cs.gsu.edu/~matggbx
    http://tinman.cs.gsu.edu:9001/matlntx/plsql/main_page
    http://tinman.cs.gsu.edu/~raj/books/oracle-primer.html
    http://www.amazon.com/exec/obidos/ASIN/0201357534/002-8465435-3334227

  2. Write a Java program, called WebNBA.java, which prompts the user for the name (such as hawks, bulls etc.) of an NBA team. It then prints the name of the head coach and the names and universities of the players in the roster. The URL to obtain this information for the Chicago Bulls, for example, is
      http://www.nba.com/bulls/roster.html
    A sample run of the program is shown below.
    A:> java WebNBA
    Enter Team Name (in lower case; e.g. bulls): hawks
    
    Head Coach is Lenny Wilkens
    
    The roster is:
    
    Mookie Blaylock ( Oklahoma '89)
    Tyrone Corbin ( DePaul '85)
    Chris Crawford ( Marquette '97)
    LaPhonso Ellis ( Notre Dame '92)
    Ed Gray ( California '97)
    Alan Henderson ( Indiana '95)
    Anthony Johnson ( Charleston (SC) '97)
    Grant Long ( Eastern Michigan '88)
    Roshown McLeod ( Duke '98)
    Dikembe Mutombo ( Georgetown '91)
    Jeff Sheppard ( Kentucky)
    Steve Smith ( Michigan State '91)
    Mark West ( Old Dominion '83)

For both these problems, you need to use the class WebAccess.java, which you should include in your ohjava directory. This class is available from the course Web page. This class has a public class method:

   public static String getHTMLContent(String urlString)
which can be used as follows:
  String htmlString = WebAccess.getHTMLContent(s);
where s is a string variable whose value is a valid URL. After getting the HTML content of a URL, you should process the string to extract the necessary information.


To solve the two problems, you will need to know the exact formatting of the HTML files which are obtained. I am posting two sample files in the course Web Page, one for each assignment. You should look at the HTML source of these files before starting to write the programs.

Please view these two pages on your browser and also save the source HTML files for these two pages.

Raj Sunderraman
Wed Mar 24 10:41:40 EST 1999