Hi all,
Thanks for your replies.
Maateen:
I am using a socket (result of ServerSocket.accept()).
Gautham & Maateen:
I have found through experamentation that the browser is sending multiple requests. The first is for the Html document. The subsequent requests are for the embedded document items (jpeg, etc.) This information is in the headers forwarded by the browser.
So the solution was:
1) open the socket
2) read the request
3) identify the resource requested
4) send the resource to the browser
5) close the socket
This logic is in a loop based off the ServerSocket.accept(), so each new request opens a new socket.
By the way RFC2616 says that in Http 1.1 protocol you should keep the socket open, but the ServerSocket.accept() method opens a new socket with each request, so I'm closing them when I process the request.
Thanks,
VG