Web Client Programming with Java
Web Client Programming with Java
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
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
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 five steps:
I/O Across a URLConnection
For example,
Reading Header Data
getHeaderFieldKey()
For example
getHeaderFieldInt() and getHeaderFieldDate()
Six Convenience Methods
Example
Writing data to a URLConnection
Eight Steps:
POST CGIs
A POST request includes
Posting Forms
HttpURLConnection
Recall
Response Codes
HTTP Protocols
disconnect()
For example,
Datagrams
Packets Allow Error Correction
Abstraction
Sockets
Socket Operations
The java.net.Socket class
Constructing a Socket
Opening Sockets
Creating Sockets
Example
Picking an IP address
Choosing a Local Port
Sending and Receiving Data
Reading Input from a Socket
For example
Writing Output to a Socket
Discard
Reading and Writing to a Socket
Write-read Protocols
Write-Read Protocols
Asynchronous protocols
Example
Socket Options
Getter Methods
Swing Supports HTML
HTML on Components
Avoid Uppercase HTML
Including HTML in a JLabel
The Actual Applet
What's Supported?
JEditorPane
JEditorPane Constructors
JEditorPane setPage() and setText()
Using a JEditorPane to display a web page
JEditorPane displaying a Web Page
What JEditorPane Doesn't Do
The second constructor
The third constructor
The fourth constructor
Constructing HTML User Interfaces on the Fly
Constructing HTML User Interfaces on the Fly, an Example
Handling Hyperlinks
Three kinds of link event
HyperlinkListener Example
A very simple web browser
To Learn More
Questions?
Start
|
Cafe con Leche
Copyright 1999, 2000
Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified July 22, 2000