Testing supported protocols
27 June 2008Consider 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"); } } } }
Related Posts:
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