Java Web Page Retrieval via a Proxy


getPage1.java retrieves the Web page http://www.cs.ait.ac.th/~ad and prints it to standard output a line at a time.

It's interesting feature is the use of the ProxyDetails class in order to work through a proxy/firewall and to deliver optional authorization details (i.e. a login and password).

If getPage1 is called in the normal way:

  java getPage1

Then no proxy or authorization information is used. However, if the call is:

  java getPage1 -proxy

then ProxyDetails reads in proxyInfo.txt. It should contain proxy host and port information for accessing the proxy, and an optional authorization ID (login). If the ID line is found then the class will also prompt the user for a password via a dialog box.

ProxyDetails uses Base64Converter to encode its authorization strings.

Code Summary


Andrew Davison
Last updated: June 7th, 2001