Read Client URL request from server socket

Go To StackoverFlow.com

1

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: https://your.server.com?usr=user_name, I would like to read this url from the server's end.

Thanks!

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


0

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


0

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

http://myhost:myport

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

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