Testing supported protocols

27 June 2008

Consider the following scenario: You are asked to test your browser with a list of protocols. So, you can do this by making URL objects for a host with each protocol. If object is created, it means protocol is supported, in other case, it simply means that the browser does not support the particular protocol.

Review the applet code below:

public class ProtocolTesterApplet extends Applet {
 
  TextArea results = new TextArea( );  
 
  public void init( ) {
 
    this.setLayout(new BorderLayout( ));    
 
    this.add("Center", results);
 
  }
 
  public void start( ) {
    String host = "http://content-uk.cricinfo.com";
    String file = "/ci/content/current/story/index.html";
 
    String[] schemes = {"http", "https", "ftp", "mailto", 
                        "telnet", "file",    "ldap", "gopher",
                        "jdbc",   "rmi",     "jndi", "jar",
                        "doc",    "netdoc",  "nfs",  "verbatim",
                        "finger", "daytime", "systemresource"};
 
    for (int i = 0; i < schemes.length; i++) {
      try {
 
        URL u = new URL(schemes[i], host, file);
        results.append(schemes[i] + " is supported\r\n");
      }
 
      catch (MalformedURLException ex) {
 
        results.append(schemes[i] + " is not supported\r\n");      
 
      }
    }  
  }
 
}

del.icio.us:Testing supported protocols  digg:Testing supported protocols  spurl:Testing supported protocols  wists:Testing supported protocols  simpy:Testing supported protocols  newsvine:Testing supported protocols  blinklist:Testing supported protocols  furl:Testing supported protocols  reddit:Testing supported protocols  fark:Testing supported protocols  blogmarks:Testing supported protocols  Y!:Testing supported protocols  smarking:Testing supported protocols  magnolia:Testing supported protocols  segnalo:Testing supported protocols  gifttagging:Testing supported protocols

Top Of Page | Trackback

If you found this page useful, consider linking to it. Simply copy and paste the code below into your web site.

It will look like this: Testing supported protocols

Leave a Reply