14sockets - Networking in Java Networking is a massive and...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Networking in Java Networking is a massive and complex topic, whole courses are devoted to this subject Java provides a rich set of networking capabilities Ranging from manipulating URLs on the Internet to client-server systems connecting via sockets or distributed systems via JavaBeans or CORBA package java.net.* includes classes for URLs, sockets and other networking features Manipulating URLs URLs (Uniform Resource Locators) are the basis of the World Wide Web class URL stores the URL of a website: See http://www.eecs.lehigh.edu/~glennb/oose/java/netlinks.java This is the crucial code, using method getAppletContext to display a URL: try { URL site = new URL(webURLs[index]); getAppletContext().showDocument(site); } catch (MalformedURLException m){System.exit(1);} URL constructor determines a String represents a valid Uniform Resource Locator If not, it generates a MalformedURLException Applet’s method getAppletContext attempts to access the URL site If successful, AppletContext’s showdocument method displays the URL into an applet window Another version of showdocument takes a second String argument representing the target frame: Target frame “_blank” results in a new frame, “_self” results it into the same frame A URL can also be used to open an InputStream from a file on a server and read its content
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 08/06/2008 for the course CSE 432 taught by Professor Blank during the Fall '08 term at Lehigh University .

Page1 / 5

14sockets - Networking in Java Networking is a massive and...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online