[11411] in www-talk@info.cern.ch
http server design
daemon@ATHENA.MIT.EDU (Mukul Gandhi)
Tue Aug 3 07:36:44 1999
Date: Tue, 03 Aug 1999 16:54:58 -0400
To: www-talk@w3.org
From: Mukul Gandhi <mgandhi@mtcindia.com>
Resent-From: www-talk@w3.org
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