import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
public class WebServer{ public static void main(String[] args)throws Exception{
ServerSocket ss=new ServerSocket(80);
Socket s=null;
while((s=ss.accept())!=null)
{ new HTTPThread(s).start(); }
ss.close();
}
}
class HTTPThread extends Thread{
private Socket socket;
public HTTPThread(Socket socket){
super();
this.socket=socket;
}
public void run(){
try{
OutputStream os=socket.getOutputStream();
PrintWriter pw=new PrintWriter(os);
pw.println("<html>");
pw.println("<body>");
pw.println("hi this my first web page");
pw.println("</body>");
pw.println("</html>");
pw.flush();
pw.close();
socket.close();
} catch(IOException e)
{
e.printStackTrace();
}
}
}
就你贴出的代码,鬼知道你想要显示出什么