You are previewing Java Network Programming, 3rd Edition.
O'Reilly logo
Java Network Programming, 3rd Edition

Book Description

The new third edition of this highly regarded introduction to Java networking programming has been thoroughly revised to cover all of the 100+ significant updates to Java Developers Kit (JDK) 1.5. It is a clear, complete introduction to developing network programs (both applets and applications) using Java, covering everything from networking fundamentals to remote method invocation (RMI). Java Network Programming, 3rd Edition includes chapters on TCP and UDP sockets, multicasting protocol and content handlers, servlets, multithreaded network programming, I/O, HTML parsing and display, the Java Mail API, and the Java Secure Sockets Extension. There's also significant information on the New I/O API that was developed in large part because of the needs of network programmers. This invaluable book is a complete, single source guide to writing sophisticated network applications. Packed with useful examples, it is the essential resource for any serious Java developer.

Table of Contents

  1. Special Upgrade Offer
  2. A Note Regarding Supplemental Files
  3. Preface
    1. About the Third Edition
    2. Organization of the Book
    3. Who You Are
    4. Java Versions
    5. About the Examples
    6. Conventions Used in This Book
    7. Request for Comments
    8. Comments and Questions
    9. Acknowledgments
  4. 1. Why Networked Java?
    1. 1.1. What Can a Network Program Do?
      1. 1.1.1. Retrieve Data
      2. 1.1.2. Send Data
        1. 1.1.2.1. File storage
        2. 1.1.2.2. Massively parallel computing
      3. 1.1.3. Peer-to-Peer Interaction
        1. 1.1.3.1. Games
        2. 1.1.3.2. Chat
        3. 1.1.3.3. File sharing
      4. 1.1.4. Servers
      5. 1.1.5. Searching the Web
      6. 1.1.6. Electronic Commerce
      7. 1.1.7. Ubiquitous Computing
      8. 1.1.8. Interactive Television
    2. 1.2. Security
    3. 1.3. But Wait! There’s More!
  5. 2. Basic Network Concepts
    1. 2.1. Networks
    2. 2.2. The Layers of a Network
      1. 2.2.1. The Host-to-Network Layer
      2. 2.2.2. The Internet Layer
      3. 2.2.3. The Transport Layer
      4. 2.2.4. The Application Layer
    3. 2.3. IP, TCP, and UDP
      1. 2.3.1. IP Addresses and Domain Names
      2. 2.3.2. Ports
    4. 2.4. The Internet
      1. 2.4.1. Internet Address Classes
      2. 2.4.2. Network Address Translation
      3. 2.4.3. Firewalls
      4. 2.4.4. Proxy Servers
    5. 2.5. The Client/Server Model
    6. 2.6. Internet Standards
      1. 2.6.1. IETF RFCs
      2. 2.6.2. W3C Recommendations
  6. 3. Basic Web Concepts
    1. 3.1. URIs
      1. 3.1.1. URNs
      2. 3.1.2. URLs
      3. 3.1.3. Relative URLs
    2. 3.2. HTML, SGML, and XML
    3. 3.3. HTTP
    4. 3.4. MIME Media Types
    5. 3.5. Server-Side Programs
  7. 4. Streams
    1. 4.1. Output Streams
    2. 4.2. Input Streams
      1. 4.2.1. Marking and Resetting
    3. 4.3. Filter Streams
      1. 4.3.1. Chaining Filters Together
      2. 4.3.2. Buffered Streams
      3. 4.3.3. PrintStream
      4. 4.3.4. PushbackInputStream
      5. 4.3.5. Data Streams
      6. 4.3.6. Compressing Streams
      7. 4.3.7. Digest Streams
      8. 4.3.8. Encrypting Streams
    4. 4.4. Readers and Writers
      1. 4.4.1. Writers
      2. 4.4.2. OutputStreamWriter
      3. 4.4.3. Readers
      4. 4.4.4. Filter Readers and Writers
        1. 4.4.4.1. Buffered readers and writers
        2. 4.4.4.2. LineNumberReader
        3. 4.4.4.3. PushbackReader
        4. 4.4.4.4. PrintWriter
  8. 5. Threads
    1. 5.1. Running Threads
      1. 5.1.1. Subclassing Thread
      2. 5.1.2. Implementing the Runnable Interface
    2. 5.2. Returning Information from a Thread
      1. 5.2.1. Race Conditions
      2. 5.2.2. Polling
      3. 5.2.3. Callbacks
    3. 5.3. Synchronization
      1. 5.3.1. Synchronized Blocks
      2. 5.3.2. Synchronized Methods
      3. 5.3.3. Alternatives to Synchronization
    4. 5.4. Deadlock
    5. 5.5. Thread Scheduling
      1. 5.5.1. Priorities
      2. 5.5.2. Preemption
        1. 5.5.2.1. Blocking
        2. 5.5.2.2. Yielding
        3. 5.5.2.3. Sleeping
        4. 5.5.2.4. Joining threads
        5. 5.5.2.5. Waiting on an object
        6. 5.5.2.6. Priority-based preemption
        7. 5.5.2.7. Finish
    6. 5.6. Thread Pools
  9. 6. Looking Up Internet Addresses
    1. 6.1. The InetAddress Class
      1. 6.1.1. Creating New InetAddress Objects
        1. 6.1.1.1. public static InetAddress getByName(String hostName) throws UnknownHostException
        2. 6.1.1.2. public static InetAddress[ ] getAllByName(String hostName) throws UnknownHostException
        3. 6.1.1.3. public static InetAddress getByAddress(byte[ ] address) throws UnknownHostException // Java 1.4public static InetAddress getByAddress(String hostName, byte[] address) throws UnknownHostException // Java 1.4
        4. 6.1.1.4. public static InetAddress getLocalHost( ) throws UnknownHostException
      2. 6.1.2. Security Issues
      3. 6.1.3. Getter Methods
        1. 6.1.3.1. public String getHostName( )
        2. 6.1.3.2. public String getHostAddress( )
        3. 6.1.3.3. public byte[] getAddress( )
      4. 6.1.4. Address Types
        1. 6.1.4.1. public boolean isAnyLocalAddress( )
        2. 6.1.4.2. public boolean isLoopbackAddress( )
        3. 6.1.4.3. public boolean isLinkLocalAddress( )
        4. 6.1.4.4. public boolean isSiteLocalAddress( )
        5. 6.1.4.5. public boolean isMulticastAddress( )
        6. 6.1.4.6. public boolean isMCGlobal( )
        7. 6.1.4.7. public boolean isMCOrgLocal( )
        8. 6.1.4.8. public boolean isMCSiteLocal( )
        9. 6.1.4.9. public boolean isMCLinkLocal( )
        10. 6.1.4.10. public boolean isMCNodeLocal( )
      5. 6.1.5. Testing Reachability // Java 1.5
      6. 6.1.6. Object Methods
        1. 6.1.6.1. public boolean equals(Object o)
        2. 6.1.6.2. public int hashCode( )
        3. 6.1.6.3. public String toString( )
    2. 6.2. Inet4Address and Inet6Address
    3. 6.3. The NetworkInterface Class
      1. 6.3.1. Factory Methods
        1. 6.3.1.1. public static NetworkInterface getByName(String name) throws SocketException
        2. 6.3.1.2. public static NetworkInterface getByInetAddress(InetAddress address) throws SocketException
        3. 6.3.1.3. public static Enumeration getNetworkInterfaces( ) throws SocketException
      2. 6.3.2. Getter Methods
        1. 6.3.2.1. public Enumeration getInetAddresses( )
        2. 6.3.2.2. public String getName( )
        3. 6.3.2.3. public String getDisplayName( )
      3. 6.3.3. Object Methods
    4. 6.4. Some Useful Programs
      1. 6.4.1. HostLookup
      2. 6.4.2. Processing Web Server Log Files
  10. 7. URLs and URIs
    1. 7.1. The URL Class
      1. 7.1.1. Creating New URLs
        1. 7.1.1.1. Constructing a URL from a string
        2. 7.1.1.2. Constructing a URL from its component parts
        3. 7.1.1.3. Constructing relative URLs
        4. 7.1.1.4. Specifying a URLStreamHandler // Java 1.2
        5. 7.1.1.5. Other sources of URL objects
      2. 7.1.2. Splitting a URL into Pieces
        1. 7.1.2.1. public String getProtocol( )
        2. 7.1.2.2. public String getHost( )
        3. 7.1.2.3. public int getPort( )
        4. 7.1.2.4. public int getDefaultPort( )
        5. 7.1.2.5. public String getFile( )
        6. 7.1.2.6. public String getPath( ) // Java 1.3
        7. 7.1.2.7. public String getRef( )
        8. 7.1.2.8. public String getQuery( ) // Java 1.3
        9. 7.1.2.9. public String getUserInfo( ) // Java 1.3
        10. 7.1.2.10. public String getAuthority( ) // Java 1.3
      3. 7.1.3. Retrieving Data from a URL
        1. 7.1.3.1. public final InputStream openStream( ) throws IOException
        2. 7.1.3.2. public URLConnection openConnection( ) throws IOException
        3. 7.1.3.3. public final Object getContent( ) throws IOException
        4. 7.1.3.4. public final Object getContent(Class[] classes) throws IOException // Java 1.3
      4. 7.1.4. Utility Methods
        1. 7.1.4.1. public boolean sameFile(URL other)
        2. 7.1.4.2. public String toExternalForm( )
        3. 7.1.4.3. public URI toURI( ) throws URISyntaxException // Java 1.5
      5. 7.1.5. The Object Methods
        1. 7.1.5.1. public String toString( )
        2. 7.1.5.2. public boolean equals(Object o)
        3. 7.1.5.3. public int hashCode( )
      6. 7.1.6. Methods for Protocol Handlers
        1. 7.1.6.1. public static synchronized void setURLStreamHandlerFactory(URLStreamHandlerFactory factory)
    2. 7.2. The URLEncoder and URLDecoder Classes
      1. 7.2.1. URLEncoder
      2. 7.2.2. URLDecoder
    3. 7.3. The URI Class
      1. 7.3.1. Constructing a URI
        1. 7.3.1.1. public URI(String uri) throws URISyntaxException
        2. 7.3.1.2. public URI(String scheme, String schemeSpecificPart, String fragment) throws URISyntaxException
        3. 7.3.1.3. public URI(String scheme, String host, String path, String fragment) throws URISyntaxException
        4. 7.3.1.4. public URI(String scheme, String authority, String path, String query, String fragment) throws URISyntaxException
        5. 7.3.1.5. public URI(String scheme, String userInfo, String host, int port, String path, String query, String fragment) throws URISyntaxException
        6. 7.3.1.6. public static URI create(String uri)
      2. 7.3.2. The Parts of the URI
      3. 7.3.3. Resolving Relative URIs
        1. 7.3.3.1. public URI resolve(URI uri)
        2. 7.3.3.2. public URI resolve(String uri)
        3. 7.3.3.3. public URI relativize(URI uri)
      4. 7.3.4. Utility Methods
        1. 7.3.4.1. public boolean equals(Object o)
        2. 7.3.4.2. public int hashCode( )
        3. 7.3.4.3. public int compareTo(Object o)
        4. 7.3.4.4. public String toString( )
        5. 7.3.4.5. public String toASCIIString( )
    4. 7.4. Proxies
      1. 7.4.1. System Properties
      2. 7.4.2. The Proxy Class
      3. 7.4.3. The ProxySelector Class
    5. 7.5. Communicating with Server-Side Programs Through GET
    6. 7.6. Accessing Password-Protected Sites
      1. 7.6.1. The Authenticator Class
      2. 7.6.2. The PasswordAuthentication Class
      3. 7.6.3. The JPasswordField Class
  11. 8. HTML in Swing
    1. 8.1. HTML on Components
    2. 8.2. JEditorPane
      1. 8.2.1. Constructing HTML User Interfaces on the Fly
      2. 8.2.2. Handling Hyperlinks
      3. 8.2.3. Reading HTML Directly
    3. 8.3. Parsing HTML
      1. 8.3.1. HTMLEditorKit.Parser
      2. 8.3.2. HTMLEditorKit.ParserCallback
      3. 8.3.3. HTML.Tag
      4. 8.3.4. Attributes
    4. 8.4. Cookies
  12. 9. Sockets for Clients
    1. 9.1. Socket Basics
    2. 9.2. Investigating Protocols with Telnet
    3. 9.3. The Socket Class
      1. 9.3.1. The Constructors
        1. 9.3.1.1. public Socket(String host, int port) throws UnknownHostException, IOException
        2. 9.3.1.2. public Socket(InetAddress host, int port) throws IOException
        3. 9.3.1.3. public Socket(String host, int port, InetAddress interface, int localPort) throws IOException, UnknownHostException
        4. 9.3.1.4. public Socket(InetAddress host, int port, InetAddress interface, int localPort) throws IOException
        5. 9.3.1.5. protected Socket( )
        6. 9.3.1.6. protected Socket(SocketImpl impl)
        7. 9.3.1.7. public Socket(Proxy proxy) // Java 1.5
      2. 9.3.2. Getting Information About a Socket
        1. 9.3.2.1. public InetAddress getInetAddress( )
        2. 9.3.2.2. public int getPort( )
        3. 9.3.2.3. public int getLocalPort( )
        4. 9.3.2.4. public InetAddress getLocalAddress( )
        5. 9.3.2.5. public InputStream getInputStream( ) throws IOException
        6. 9.3.2.6. public OutputStream getOutputStream( ) throws IOException
      3. 9.3.3. Closing the Socket
        1. 9.3.3.1. public void close( ) throws IOException
        2. 9.3.3.2. Half-closed sockets // Java 1.3
      4. 9.3.4. Setting Socket Options
        1. 9.3.4.1. TCP_NODELAY
        2. 9.3.4.2. SO_LINGER
        3. 9.3.4.3. SO_TIMEOUT
        4. 9.3.4.4. SO_RCVBUF
        5. 9.3.4.5. SO_SNDBUF
        6. 9.3.4.6. SO_KEEPALIVE
        7. 9.3.4.7. OOBINLINE // Java 1.4
        8. 9.3.4.8. SO_REUSEADDR // Java 1.4
      5. 9.3.5. Class of Service
      6. 9.3.6. The Object Methods
        1. 9.3.6.1. public String toString( )
    4. 9.4. Socket Exceptions
    5. 9.5. Socket Addresses
    6. 9.6. Examples
      1. 9.6.1. Finger
      2. 9.6.2. Whois
  13. 10. Sockets for Servers
    1. 10.1. The ServerSocket Class
      1. 10.1.1. The Constructors
        1. 10.1.1.1. public ServerSocket(int port) throws BindException, IOException
        2. 10.1.1.2. public ServerSocket(int port, int queueLength) throws IOException, BindException
        3. 10.1.1.3. public ServerSocket(int port, int queueLength, InetAddress bindAddress) throws BindException, IOException
        4. 10.1.1.4. public ServerSocket( ) throws IOException // Java 1.4
      2. 10.1.2. Accepting and Closing Connections
        1. 10.1.2.1. public Socket accept( ) throws IOException
        2. 10.1.2.2. public void close( ) throws IOException
      3. 10.1.3. The get Methods
        1. 10.1.3.1. public InetAddress getInetAddress( )
        2. 10.1.3.2. public int getLocalPort( )
      4. 10.1.4. Socket Options
        1. 10.1.4.1. SO_TIMEOUT
        2. 10.1.4.2. SO_REUSEADDR // Java 1.4
        3. 10.1.4.3. SO_RCVBUF // Java 1.4
        4. 10.1.4.4. public void setPerformancePreferences(int connectionTime, int latency, int bandwidth) // Java 1.5
      5. 10.1.5. The Object Methods
        1. 10.1.5.1. public String toString( )
      6. 10.1.6. Implementation
        1. 10.1.6.1. public static void setSocketFactory(SocketImplFactory factory) throws IOException
        2. 10.1.6.2. protected final void implAccept(Socket s) throws IOException
    2. 10.2. Some Useful Servers
      1. 10.2.1. Client Tester
      2. 10.2.2. HTTP Servers
        1. 10.2.2.1. A single-file server
        2. 10.2.2.2. A redirector
        3. 10.2.2.3. A full-fledged HTTP server
  14. 11. Secure Sockets
    1. 11.1. Secure Communications
    2. 11.2. Creating Secure Client Sockets
    3. 11.3. Methods of the SSLSocket Class
      1. 11.3.1. Choosing the Cipher Suites
      2. 11.3.2. Event Handlers
      3. 11.3.3. Session Management
      4. 11.3.4. Client Mode
    4. 11.4. Creating Secure Server Sockets
    5. 11.5. Methods of the SSLServerSocket Class
      1. 11.5.1. Choosing the Cipher Suites
      2. 11.5.2. Session Management
      3. 11.5.3. Client Mode
  15. 12. Non-Blocking I/O
    1. 12.1. An Example Client
    2. 12.2. An Example Server
    3. 12.3. Buffers
      1. 12.3.1. Creating Buffers
        1. 12.3.1.1. Allocation
        2. 12.3.1.2. Direct allocation
        3. 12.3.1.3. Wrapping
      2. 12.3.2. Filling and Draining
      3. 12.3.3. Bulk Methods
      4. 12.3.4. Data Conversion
      5. 12.3.5. View Buffers
      6. 12.3.6. Compacting Buffers
      7. 12.3.7. Duplicating Buffers
      8. 12.3.8. Slicing Buffers
      9. 12.3.9. Marking and Resetting
      10. 12.3.10. Object Methods
    4. 12.4. Channels
      1. 12.4.1. SocketChannel
        1. 12.4.1.1. Connecting
        2. 12.4.1.2. Reading
        3. 12.4.1.3. Writing
        4. 12.4.1.4. Closing
      2. 12.4.2. ServerSocketChannel
        1. 12.4.2.1. Creating server socket channels
        2. 12.4.2.2. Accepting connections
      3. 12.4.3. The Channels Class
    5. 12.5. Readiness Selection
      1. 12.5.1. The Selector Class
      2. 12.5.2. The SelectionKey Class
  16. 13. UDP Datagrams and Sockets
    1. 13.1. The UDP Protocol
    2. 13.2. The DatagramPacket Class
      1. 13.2.1. The Constructors
        1. 13.2.1.1. Constructors for receiving datagrams
        2. 13.2.1.2. Constructors for sending datagrams
      2. 13.2.2. The get Methods
        1. 13.2.2.1. public InetAddress getAddress( )
        2. 13.2.2.2. public int getPort( )
        3. 13.2.2.3. public SocketAddress getSocketAddress( ) // Java 1.4
        4. 13.2.2.4. public byte[] getData( )
        5. 13.2.2.5. public int getLength( )
        6. 13.2.2.6. public int getOffset( ) // Java 1.2
      3. 13.2.3. The set Methods
        1. 13.2.3.1. public void setData(byte[] data)
        2. 13.2.3.2. public void setData(byte[] data, int offset, int length) // Java 1.2
        3. 13.2.3.3. public void setAddress(InetAddress remote)
        4. 13.2.3.4. public void setPort(int port)
        5. 13.2.3.5. public void setAddress(SocketAddress remote) // Java 1.4
        6. 13.2.3.6. public void setLength(int length)
    3. 13.3. The DatagramSocket Class
      1. 13.3.1. The Constructors
        1. 13.3.1.1. public DatagramSocket( ) throws SocketException
        2. 13.3.1.2. public DatagramSocket(int port) throws SocketException
        3. 13.3.1.3. public DatagramSocket(int port, InetAddress interface) throws SocketException
        4. 13.3.1.4. public DatagramSocket(SocketAddress interface) throws SocketException // Java 1.4
        5. 13.3.1.5. protected DatagramSocket(DatagramSocketImpl impl) throws SocketException // Java 1.4
      2. 13.3.2. Sending and Receiving Datagrams
        1. 13.3.2.1. public void send(DatagramPacket dp) throws IOException
        2. 13.3.2.2. public void receive(DatagramPacket dp) throws IOException
        3. 13.3.2.3. public void close( )
        4. 13.3.2.4. public int getLocalPort( )
        5. 13.3.2.5. public InetAddress getLocalAddress( )
        6. 13.3.2.6. public SocketAddress getLocalSocketAddress( ) // Java 1.4
      3. 13.3.3. Managing Connections
        1. 13.3.3.1. public void connect(InetAddress host, int port) // Java 1.2
        2. 13.3.3.2. public void disconnect( ) // Java 1.2
        3. 13.3.3.3. public int getPort( ) // Java 1.2
        4. 13.3.3.4. public InetAddress getInetAddress( ) // Java 1.2
        5. 13.3.3.5. public InetAddress getRemoteSocketAddress( ) // Java 1.4
      4. 13.3.4. Socket Options
        1. 13.3.4.1. SO_TIMEOUT
        2. 13.3.4.2. SO_RCVBUF
        3. 13.3.4.3. SO_SNDBUF
        4. 13.3.4.4. SO_REUSEADDR
        5. 13.3.4.5. SO_BROADCAST
        6. 13.3.4.6. Traffic class
    4. 13.4. Some Useful Applications
      1. 13.4.1. Simple UDP Clients
      2. 13.4.2. UDPServer
      3. 13.4.3. A UDP Echo Client
    5. 13.5. DatagramChannel
      1. 13.5.1. Using DatagramChannel
        1. 13.5.1.1. Opening a socket
        2. 13.5.1.2. Connecting
        3. 13.5.1.3. Receiving
        4. 13.5.1.4. Sending
        5. 13.5.1.5. Reading
        6. 13.5.1.6. Writing
        7. 13.5.1.7. Closing
  17. 14. Multicast Sockets
    1. 14.1. What Is a Multicast Socket?
      1. 14.1.1. Multicast Addresses and Groups
      2. 14.1.2. Clients and Servers
      3. 14.1.3. Routers and Routing
    2. 14.2. Working with Multicast Sockets
      1. 14.2.1. The Constructors
        1. 14.2.1.1. public MulticastSocket( ) throws SocketException
        2. 14.2.1.2. public MulticastSocket(int port) throws SocketException
        3. 14.2.1.3. public MulticastSocket(SocketAddress bindAddress) throws IOException // Java 1.4
      2. 14.2.2. Communicating with a Multicast Group
        1. 14.2.2.1. public void joinGroup(InetAddress address) throws IOException
        2. 14.2.2.2. public void joinGroup(SocketAddress address, NetworkInterface interface) throws IOException // Java 1.4
        3. 14.2.2.3. public void leaveGroup(InetAddress address) throws IOException
        4. 14.2.2.4. public void leaveGroup(SocketAddress multicastAddress, NetworkInterface interface) throws IOException // Java 1.4
        5. 14.2.2.5. public void send(DatagramPacket packet, byte ttl) throws IOException
        6. 14.2.2.6. public void setInterface(InetAddress address) throws SocketException
        7. 14.2.2.7. public InetAddress getInterface( ) throws SocketException
        8. 14.2.2.8. public void setNetworkInterface(NetworkInterface interface) throws SocketException // Java 1.4
        9. 14.2.2.9. public NetworkInterface getNetworkInterface( ) throws SocketException // Java 1.4
        10. 14.2.2.10. public void setTimeToLive(int ttl) throws IOException // Java 1.2
        11. 14.2.2.11. public int getTimeToLive( ) throws IOException // Java 1.2
        12. 14.2.2.12. public void setLoopbackMode(boolean disable) throws SocketException // Java 1.4
        13. 14.2.2.13. public boolean getLoopbackMode( ) throws SocketException // Java 1.4
    3. 14.3. Two Simple Examples
  18. 15. URLConnections
    1. 15.1. Opening URLConnections
    2. 15.2. Reading Data from a Server
    3. 15.3. Reading the Header
      1. 15.3.1. Retrieving Specific Header Fields
        1. 15.3.1.1. public String getContentType( )
        2. 15.3.1.2. public int getContentLength( )
        3. 15.3.1.3. public String getContentEncoding( )
        4. 15.3.1.4. public long getDate( )
        5. 15.3.1.5. public long getExpiration( )
        6. 15.3.1.6. public long getLastModified( )
      2. 15.3.2. Retrieving Arbitrary Header Fields
        1. 15.3.2.1. public String getHeaderField(String name)
        2. 15.3.2.2. public String getHeaderFieldKey(int n)
        3. 15.3.2.3. public String getHeaderField(int n)
        4. 15.3.2.4. public long getHeaderFieldDate(String name, long default)
        5. 15.3.2.5. public int getHeaderFieldInt(String name, int default)
    4. 15.4. Configuring the Connection
      1. 15.4.1. protected URL url
      2. 15.4.2. protected boolean connected
      3. 15.4.3. protected boolean allowUserInteraction
      4. 15.4.4. protected boolean doInput
      5. 15.4.5. protected boolean doOutput
      6. 15.4.6. protected boolean ifModifiedSince
      7. 15.4.7. protected boolean useCaches
      8. 15.4.8. Timeouts
    5. 15.5. Configuring the Client Request HTTP Header
    6. 15.6. Writing Data to a Server
    7. 15.7. Content Handlers
      1. 15.7.1. Getting Content
        1. 15.7.1.1. public Object getContent( ) throws IOException
        2. 15.7.1.2. public Object getContent(Class[] classes) throws IOException // Java 1.3
      2. 15.7.2. ContentHandlerFactory
    8. 15.8. The Object Methods
    9. 15.9. Security Considerations for URLConnections
    10. 15.10. Guessing MIME Content Types
    11. 15.11. HttpURLConnection
      1. 15.11.1. The Request Method
        1. 15.11.1.1. HEAD
        2. 15.11.1.2. OPTIONS
        3. 15.11.1.3. DELETE
        4. 15.11.1.4. PUT
        5. 15.11.1.5. TRACE
      2. 15.11.2. Disconnecting from the Server
      3. 15.11.3. Handling Server Responses
        1. 15.11.3.1. Error conditions
        2. 15.11.3.2. Redirects
      4. 15.11.4. Proxies
      5. 15.11.5. Streaming Mode
    12. 15.12. Caches
    13. 15.13. JarURLConnection
  19. 16. Protocol Handlers
    1. 16.1. What Is a Protocol Handler?
    2. 16.2. The URLStreamHandler Class
      1. 16.2.1. The Constructor
      2. 16.2.2. Methods for Parsing URLs
        1. 16.2.2.1. protected void parseURL(URL u, String spec, int start, int limit)
        2. 16.2.2.2. protected String toExternalForm(URL u)
        3. 16.2.2.3. protected void setURL(URL u, String protocol, String host, int port, String authority, String userInfo, String path, String query, String fragmentID) // Java 1.3
        4. 16.2.2.4. protected int getDefaultPort( ) // Java 1.3
        5. 16.2.2.5. protected InetAddress getHostAddress(URL u) // Java 1.3
        6. 16.2.2.6. protected boolean hostsEqual(URL u1, URL u2) // Java 1.3
        7. 16.2.2.7. protected boolean sameFile(URL u1, URL u2) // Java 1.3
        8. 16.2.2.8. protected boolean equals(URL u1, URL u2) // Java 1.3
        9. 16.2.2.9. protected int hashCode(URL u) // Java 1.3
      3. 16.2.3. A Method for Connecting
        1. 16.2.3.1. protected abstract URLConnection openConnection(URL u) throws IOException
        2. 16.2.3.2. protected URLConnection openConnection(URL u, Proxy p) throws IOException // Java 1.5
    3. 16.3. Writing a Protocol Handler
    4. 16.4. More Protocol Handler Examples and Techniques
      1. 16.4.1. A daytime Protocol Handler
      2. 16.4.2. A chargen Protocol Handler
    5. 16.5. The URLStreamHandlerFactory Interface
  20. 17. Content Handlers
    1. 17.1. What Is a Content Handler?
    2. 17.2. The ContentHandler Class
      1. 17.2.1. A Content Handler for Tab-Separated Values
      2. 17.2.2. Using Content Handlers
      3. 17.2.3. Choosing Return Types
    3. 17.3. The ContentHandlerFactory Interface
      1. 17.3.1. The createContentHandler( ) Method
      2. 17.3.2. Installing Content Handler Factories
    4. 17.4. A Content Handler for the FITS Image Format
  21. 18. Remote Method Invocation
    1. 18.1. What Is Remote Method Invocation?
      1. 18.1.1. Object Serialization
      2. 18.1.2. Under the Hood
    2. 18.2. Implementation
      1. 18.2.1. The Server Side
      2. 18.2.2. Compiling the Stubs
      3. 18.2.3. Starting the Server
      4. 18.2.4. The Client Side
      5. 18.2.5. Running the Client
    3. 18.3. Loading Classes at Runtime
    4. 18.4. The java.rmi Package
      1. 18.4.1. The Remote Interface
      2. 18.4.2. The Naming Class
        1. 18.4.2.1. public static String[] list(String url) throws RemoteException, MalformedURLException
        2. 18.4.2.2. public static Remote lookup(String url) throws RemoteException, NotBoundException, AccessException, MalformedURLException
        3. 18.4.2.3. public static void bind(String url, Remote object) throws RemoteException, AlreadyBoundException, MalformedURLException, AccessException
        4. 18.4.2.4. public static void unbind(String url) throws RemoteException, NotBoundException, AlreadyBoundException, MalformedURLException, AccessException // Java 1.2
        5. 18.4.2.5. public static void rebind(String url, Remote object) throws RemoteException, AccessException, MalformedURLException
      3. 18.4.3. The RMISecurityManager Class
      4. 18.4.4. Remote Exceptions
    5. 18.5. The java.rmi.registry Package
      1. 18.5.1. The Registry Interface
      2. 18.5.2. The LocateRegistry Class
    6. 18.6. The java.rmi.server Package
      1. 18.6.1. The RemoteObject Class
      2. 18.6.2. The RemoteServer Class
        1. 18.6.2.1. Constructors
        2. 18.6.2.2. Getting information about the client
        3. 18.6.2.3. Logging
      3. 18.6.3. The UnicastRemoteObject Class
      4. 18.6.4. Exceptions
  22. 19. The JavaMail API
    1. 19.1. What Is the JavaMail API?
    2. 19.2. Sending Email
      1. 19.2.1. Sending Email from an Application
      2. 19.2.2. Sending Email from an Applet
    3. 19.3. Receiving Mail
    4. 19.4. Password Authentication
    5. 19.5. Addresses
      1. 19.5.1. The Address Class
      2. 19.5.2. The InternetAddress Class
      3. 19.5.3. The NewsAddress Class
    6. 19.6. The URLName Class
      1. 19.6.1. The Constructors
      2. 19.6.2. Parsing Methods
    7. 19.7. The Message Class
      1. 19.7.1. Creating Messages
        1. 19.7.1.1. Replying to messages
        2. 19.7.1.2. Getting messages from folders
      2. 19.7.2. Basic Header Info
        1. 19.7.2.1. The From address
        2. 19.7.2.2. The Reply-to address
        3. 19.7.2.3. The recipient addresses
        4. 19.7.2.4. The subject of the message
        5. 19.7.2.5. The date of the message
        6. 19.7.2.6. Saving changes
      3. 19.7.3. Flags
      4. 19.7.4. Folders
      5. 19.7.5. Searching
    8. 19.8. The Part Interface
      1. 19.8.1. Attributes
      2. 19.8.2. Headers
      3. 19.8.3. Content
        1. 19.8.3.1. Reading the contents of the part
        2. 19.8.3.2. Writing the contents of the part
    9. 19.9. Multipart Messages and File Attachments
    10. 19.10. MIME Messages
    11. 19.11. Folders
      1. 19.11.1. Opening Folders
      2. 19.11.2. Basic Folder Info
      3. 19.11.3. Managing Folders
      4. 19.11.4. Managing Messages in Folders
      5. 19.11.5. Subscriptions
      6. 19.11.6. Listing the Contents of a Folder
      7. 19.11.7. Checking for Mail
      8. 19.11.8. Getting Messages from Folders
      9. 19.11.9. Searching Folders
      10. 19.11.10. Flags
      11. 19.11.11. Event Handling
      12. 19.11.12. Utility Methods
  23. Index
  24. About the Author
  25. Colophon
  26. Special Upgrade Offer
  27. Copyright