Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
2.10 WebClient: Talking to Web Servers Interactively
55
Listing 2.12 WebClient.java (continued)
    String portString =
      portField.getTextField().getText();
    if (portString.length() == 0) {
      report("Missing port number");
      return(false);
    }
    try {
      port = Integer.parseInt(portString);
    } catch(NumberFormatException nfe) {
      report("Illegal port number: " + portString);
      return(false);
    }
    requestLine =
      requestLineField.getTextField().getText();
    if (requestLine.length() == 0) {
      report("Missing request line");
      return(false);
    }
    getRequestHeaders();
    return(true);
  }
  private void report(String s) {
    resultArea.setText(s);
  }
  private void getRequestHeaders() {
    for(int i=0; i
      requestHeaders[i] = null;
    int headerNum = 0;
    String header =
      requestHeadersArea.getText();
    StringTokenizer tok =
      new StringTokenizer(header, "\r\n");
    while (tok.hasMoreTokens())
      requestHeaders[headerNum++] = tok.nextToken();
  }
}
HttpClient
The 
HttpClient
 class does the real network communication. It simply sends
the designated request line and request headers to the Web server, then
reads the lines that come back one at a time, placing them into a 
TextArea
until either the server closes the connection or the 
HttpClient
 is inter 
rupted by means of the 
isInterrupted
 flag. 
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