????web?????????????????????HTTPЭ?????????????????????????СС??????????????????HTTPЭ?顣????????????????????Apache??????????????Apache?????????80????

 

import java.io.*;
import java.net.*;

public class HttpRequest
{
 public static void main(String []args)throws Exception{
  //???????????
  Socket socket = new Socket("127.0.0.1"??80);
  OutputStreamWriter out = new OutputStreamWriter(socket.getOutputStream());
  //HTTP????????????????HTTP???????? httpЭ?????????????????
  StringBuffer sb = new StringBuffer();
  sb.append("GET /mypage/button.html HTTP/1.1 ");
  sb.append("Host:localhost ");
  sb.append("Accept-Language:zh-cn ");
  //sb.append("Connection:Keep-Alive ");
  //?????????
  sb.append(" ");
  //???????????????????
  out.write(sb.toString());
  out.flush();
  BufferedReader buf = new BufferedReader(
  new InputStreamReader(socket.getInputStream()));
  String str="";
  //??????????????????
  while((str=buf.readLine())!=" " && str!=null){
   System.out.println(str);
  }
  buf.close();
  socket.close();
 }
}
 


????????????????html?????????????????????????????????????????????????????????????????????????????????????????????Ч????