Page 1 2 3 4 >>  
 

Java - Web Server

OK, that makes more sense. Here's what happened.

  1. Client sent "GET / HTTP/1.0" to the server, followed by a carriage retrun
  2. Server sends back information about the server and the request contents, followed by actual contents.

So client sends Method, Requested Resource and Http Version.
Method - GET, POST, HEAD
Requested Resource - File or directory requested
Http Version - HTTP1.0 or HTTP1.1

For more detail specification about http request, please read http specification which can be found at www.w3.org.

The server receives that character based request, read in necessary parameters, lookup on the resource requested, and send back response header followed by the actual contents.
Let's just write a server program which displays client request.


[Code to view (.html)]
[Code to download (.java)]

1. ServerSocket is created with a port 80 as a parameter
2. ServerSocket awaits for connection
3. Once it receives a connection, InputStream and OutputStream are created from a client siocket
4. Request is read off the InputStream (However, I simply display them)
5.
Response is written on the OutputStream

Continue

   
     
   
[contact][about me][disclaimer]