How to send HTML as GET-Request parameter?

Posted by Mork0075 on Stack Overflow See other posts from Stack Overflow or by Mork0075
Published on 2009-05-08T09:54:34Z Indexed on 2012/11/18 17:01 UTC
Read the original article Hit count: 139

Filed under:
|
|
|

I would like to send a html string with a GET request like this with Apaches HttpClient:

http://sample.com/?html=<html><head>...

This doesnt work at the moment, i think its an encoding problem. Do you have any ideas how to do that?

method.setQueryString(new NameValuePair[] {new NameValuePair("report", "<html>....")});
client.executeMethod(method)

This fails with org.apache.commons.httpclient.NoHttpResponseException: The server localhost failed to respond. If i replace "<html>" by "test.." it works fine.

EDIT

It seams to be a problem of URL length after encoding, the server doesnt except such long URls. Sending it as POST solves the problem.

© Stack Overflow or respective owner

Related posts about java

Related posts about http