Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
2.10 WebClient: Talking to Web Servers Interactively
57
Listing 2.13 HttpClient.java (continued)
  private boolean checkHost(String host) {
    try {
      InetAddress.getByName(host);
      return(true);
    } catch(UnknownHostException uhe) {
      outputArea.setText("Bogus host: " + host);
      return(false);
    }
  }
}
NetworkClient
The 
NetworkClient
 class is a generic starting point for network clients and
is extended by 
HttpClient
. 
Listing 2.14 NetworkClient.java 
import java.net.*;  
import java.io.*;
/** A starting point for network clients. You'll need to
 *  override handleConnection, but in many cases
 *  connect can remain unchanged. It uses
 *  SocketUtil to simplify the creation of the
 *  PrintWriter and BufferedReader.
 *
 * @see SocketUtil
 */
public class NetworkClient {
  protected String host;
  protected int port;
  /** Register host and port. The connection won't
   *  actually be established until you call
   *  connect.
   *
   * @see #connect
   */
  
  public NetworkClient(String host, int port) {
    this.host = host;
    this.port = port;
  }
Second edition of this book: www.coreservlets.com; Sequel: www.moreservlets.com.
Servlet and JSP training courses by book's author: courses.coreservlets.com.






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

jsp web hosting

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Jsp Web Hosting Cheapest Web Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved