-5
String filename = "sample.html";

String sendMessage = "GET " +filename+ " HTTP/1.1 \n";

Could some one please tel me whether this is the correct way to send a "GET" request to the sever?

user3421395
  • 21
  • 1
  • 2
  • 1
    Look here: http://www.mkyong.com/java/how-to-send-http-request-getpost-in-java/, here http://stackoverflow.com/questions/2793150/how-to-use-java-net-urlconnection-to-fire-and-handle-http-requests or here: https://code.google.com/p/google-http-java-client/ – FoggyDay Mar 14 '14 at 21:26
  • The method described works fine for a webpage. In my case, i am requesting a html page which is located in my local system. – user3421395 Mar 14 '14 at 21:43

1 Answers1

1

you also should include the path "/etc/etc/" and finish with CR LF here is a properly formatted basic HTTP GET

GET /sample.html HTTP/1.1\r\n
Josiah DeWitt
  • 1,129
  • 9
  • 13