http server design

Hi,
I am writing a small http server using Java. I have written the following
code to open a server socket in the http server. TCP_PORT can be any
integer no no(e.g 100).

serv_socket = new ServerSocket(TCP_PORT);
socket = serv_socket.accept();
pw = new PrintWriter(socket.getOutputStream());

I can write some html to PrintWriter which I am able to see in the browser
as http://host:100

e.g 

pw.println("<HTML>");
pw.flush();
pw.println("<BODY>");
pw.flush();
pw.println("<H1>Hello World !</H1>");
pw.flush();
pw.println("</BODY>");
pw.flush();
pw.println("</HTML>");
pw.flush();
socket.close();

Now I want to fetch html from some .html file  e.g
http://host:100/somefile.html
I am sure I will read somefile.html line by line in my server(using file
I/O routines) and return the html to the browser. But, I want to know how
can I parse the URL inside the server code ? i.e how would I get the URL
string in the server(I will be using socket programming).

Somebody not using Java can also give useful suggestions to me.

-mukul

Received on Tuesday, 3 August 1999 07:27:57 UTC