Java high-level network programming
The classes and interfaces in the Java.NET package provide APIs available for low-level and high-level network programming. The low-level API allows you to access the network protocol directly, but you have to use low-level TCP sockets and UDP packets. High-level APIs (such as URL, URLCONNECTION and HTTPURLCONNECONNECTION, etc.) can make you more quickly develop web applications, but don't need to write a lot of code. Another article, "NetWork Programming With J2se 1.4" will tell you how to use the low-level socket for network programming. The focus of this article is placed on how to develop HTTP-based applications in the high-level API in the Java.NET package.
This article will have the following:
· Overview http
· Overview of the high-rise API of the java.net package
· Example shows how to use high-rise API
· Make a application that can download stock market
· Demonstrate how to submit data to web servers
· Overview HTTP verification and demonstrate how to protect your network resources
· Provide code instance demonstrate how to perform HTTP verification
Overview http
Hypertext Transfer Protocol, HTTP is a "request-response" application protocol. This protocol supports a fixed method such as GET, POST, PUT, DELETE, and so on. The GET method is generally requested to request resources to the server. Here are two examples of GET requests:
Get / http / 1.1
Get /Names.html http / 1.1
Alternatively, you can send data to the server using the GET and POST methods, which are different from the way data to the server:
· GET method: The input data will be sent as part of the URL
· POST method: Enter data as an independent entity
Consider the following HTML form: