Read Client URL request from server socket

Go To


I am creating a Java Server using Socket. I would like to print the URL the client applciation requested when contacting the server. That is, if the client requests:, I would like to read this url from the server's end.


2012-04-04 04:31
by skyknight
Are you creating a webserver from scratch, or are you using an existing webserver (like Jetty) - Greg Kopff 2012-04-04 04:34
Yes, I am creating a webserver from scratch - skyknight 2012-04-04 04:43
Is it the actual socket receiving/transmitting you have problem with, or parsing requests from clients - Some programmer dude 2012-04-04 05:45


It looks like everyone is doing this these days ;)

Have a look at this guy, he is doing the same: URL Parsing with Java server using Runnable class

2012-04-04 04:37
by Adi


You cannot have the complete url that client request. Look at the HTTP protocol RFC. On the first line of your message you have

GET /pub/WWW/ HTTP/1.1

so the first value is the request method and the second value is the part of the url without


then in the header fields, sometimes, you can find only the host

Host: myhost
2012-04-04 05:34
by dash1e