Académique Documents
Professionnel Documents
Culture Documents
Jan 8, 2017
Sockets
Protocols
TCP/IP
DHCP
URLs
Port80isdefaultforhttprequests
ProtocolhttpisusedforWebpages
TryURL.java
import java.net.*; // Gittleman, Example 2.2, pp. 67-68
import java.applet.Applet;
public class ShowURL extends Applet {
public void init() {
try {
URL url = new URL(getParameter("url"));
getAppletContext().showDocument(url);
}
catch(MalformedURLException e) {
e.printStackTrace();
}
}
}
import java.net.*;
showDocument(url)
getAppletContext()
Replaces the Web page currently being viewed with the given URL
catch(MalformedURLException e)
10
Applet results
First, a web page appears, with a gray rectangle for the applet
(which is just starting up)
Then the initial web page is replaced by the web page
specified by the URL
You are now in your regular browser, just as if you had typed
the URL into it
11
The End
12