Java Network Programming, Part 1: URLs, URLConnections, and InetAddresses
Java Network Programming, Part 1: URLs, URLConnections, and InetAddresses
Please turn off all
We will learn how Java handles
I assume you
Applet Network Security Restrictions
Some Background
Hosts
Internet addresses
Domain Name System (DNS)
The InetAddress Class
Creating InetAddresses
The getByName() factory method
Other ways to create InetAddress objects
Getter Methods
Utility Methods
Ports
Protocols
IETF RFCs
W3C Standards
W3C Standards
URLs
Example URLs
The Pieces of a URL
The java.net.URL class
Content and Protocol Handlers
Finding Protocol Handlers
Supported Protocols
URL Constructors
Constructing URL Objects
Constructing URL Objects in Pieces
Including the Port
Relative URLs
Constructing Relative URLs
Parsing URLs
For example,
Parsing URLs
Missing Pieces
Reading Data from a URL
Webcat
The Bug in readLine()
Webcat
CGI
Normal web surfing uses these two steps:
Forms
CGI
GET and POST
HTTP
A Typical HTTP Connection
What the client sends to the server
MIME
Browser Request MIME Header
Server Response MIME Header
Query Strings
URL Encoding
For example,
The URLEncoder class
For example,
Example
The URLDecoder class
GET URLs
URLConnections
URLConnections vs. URLs
URLConnection six steps:
I/O Across a URLConnection
For example,
Reading Header Data
getHeaderFieldKey()
For example
getHeaderFieldInt() and getHeaderFieldDate()
Example
Six Convenience Methods
Example
Writing data to a URLConnection
Eight Steps:
POST CGIs
A POST request includes
Example
Details
HttpURLConnection
Recall
Response Codes
HTTP Protocols
getRequestMethod()
disconnect()
For example,
usingProxy
Redirect Instructions
Example
Example
Following Redirects
To Learn More
Questions?
Entire Presentation as Single File
Start
|
Cafe con Leche
Copyright 2000
Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified November 8, 2000