Networking Section Index
How do I maintain cookies across separate network connections?
Java 5 introduced the abstract CookieHandler class to help with the process, though Java 5 lacks a usable implementation. You must implement yourself. Java 6 added the CookieManager for just such ...more
How do I use Java to ping a host?
Starting with Java 5, there is an isReachable() method in the InetAddress class. You can specify either a timeout or the NetworkInterface to use. For more information on the underlying Internet Co...more
How can I encode a URL String?
A URL String can be simply encoded using the static encode(String s, String enc) method within the URLEncoder class. encode(String s) has been deprecated with encode(String s, String enc) now bei...more
When using a URLConnection how can I get a specific header field returned by the server or all of them?
The URLConnection class contains various methods, which return specific header
fields or the whole lot. Specific header fields can be obtained either by their name or the position of where they ...more
How can I load a class from a remote server?
The URLClassLoader class was created specifically to facilitate the downloading of classes over a network. Three constructors are provided, the first of which simply takes a URL[] as an argument ...more
While I can certainly show the contents of a web page in a JEditorPane, how do I launch the desktop's browser with the new URL?
The JDesktop Integration Components (JDIC), available from https://jdic.dev.java.net, offers support for this:
import java.net.*;
import org.jdesktop.jdic.desktop.*;
public class LaunchURL {
...more
How can I parse a URL?
The URL class contains a variety of accessor methods, which return
the values of a URL's components. URL's use of accesors makes having
to parse a URL to gain this information a thing of the pa...more
How can I obtain an IP address from a host name?
The InetAddress class gives the programmer a solution to this problem through a process called resolution. When an IP address is obtained from an host name we call this Host Name Resolution with ...more
What is a URL and how can I construct one?
A URL (Uniform Resource Locator) represents a reference to resource on a network. The resource may take many forms. Maybe it is an image stored on a web server of that sports car youve been dream...more
How can I access an NNTP newsgroup using JSP or Servlets?
Your servlet must know how to speak NNTP, or call a library that does.
There are NNTP implementation in the following packages:
JavaMail: See the JavaMail:NNTP FAQ subtopic.
Jakarta Commons...more
HttpUrlConnection headache and the TIMEOUT
HttpUrlConnection headache and the TIMEOUT
I have many links(urls) to be checked for their activeness.
I want to set a timeout and check whether urls response within the timeout.
My final goal i...more
I'm looking for information on how to write a java program that uses a http url connection object to request data from a servlet... however, I don't want to construct a new tcp/ip connection every time I create a request.
I'm looking for information on how to write a java program that uses a http url connection object to request data from a servlet... however, I don't want to construct a new tcp/ip connection every ...more
Java application can't estabilish network connection, if the connection came up after application start. First I'm running a the java program below with no network connection. While the program running, the network connection came up, but the application can't reach it, why?
Java application can't estabilish network connection, if the connection came up after application start. First I'm running a the java program below with no network connection. While the program run...more
A SocketChannel that has registered with the Selector showing interest in both OP_READ and OP_WRITE
A SocketChannel that has registered with the Selector showing interest in both OP_READ|OP_WRITE I would expect the select() method to continously return showing that the channel isWritable() until ...more
I want to interrupt an accept()-operation on a ServerSocketChannel with jdk14.
I want to interrupt an accept()-operation on a ServerSocketChannel with jdk14. But issueing an interrupt() blocks.
here is a test program demonstrating this:
import java.net.*;
import java.nio.*;...more