Hi Chaohua, > The code is simple: > > HttpClient client = new HttpClient(); > GetMethod method = new GetMethod( myURL ); > byte[] responseBody = method.getResponseBody();
I assume there's also a call to HttpClient.execute somewhere :-) > When I sent a short a url string with few parameters , it works fine. > > But when I sent a very long url string with too many parameters, There are practical limits to the length of a URL, which are (server) implementation dependent. That's why you send long or many parameters in the message body, either form-url-encoded or as multipart-mime. If the server application is a Servlet, it won't make any difference. > org.apache.commons.httpclient.HttpRecoverableException: > org.apache.commons.httpclient.HttpRecoverableException > : Error in parsing the status line from the response: unable to find > line starting with "HTTP" > at This indicates that the server is sending nonsense. Since you know the reason, there is no point in further analysis. > For example these following parameters I need to contains them in url. > If cut them to half, it works fine. But if not, I got "unable to find > line starting with "HTTP" " > > (tblCase.CaseTypeCode = '210000' OR tblCase.CaseTypeCode = '210001' OR > tblCase.CaseTypeCode = '210002' OR tblCase.CaseTypeCode = '210003' OR > [...] > tblCase.CaseTypeCode = '250005' OR tblCase.CaseTypeCode = '262601' OR > tblCase.CaseTypeCode = '264001' OR tblCase.CaseTypeCode = '274002' OR > tblCase.CaseTypeCode = '276501') These are not parameters. Parameters look like "?n1=v1&n2=v2". Don't put that stuff in the URL, it is way too big. There is no way you can get that across reliably with a GET request. The primer has a few short paragraphs about creating POST requests and the two primary options for encoding parameters: http://wiki.apache.org/jakarta-httpclient/ForAbsoluteBeginners#head-8ce973d0347a2eba238f594c47f478035c51ea66 Here are some starters in the JavaDoc: http://jakarta.apache.org/commons/httpclient/apidocs/org/apache/commons/httpclient/methods/PostMethod.html#addParameter(java.lang.String,%20java.lang.String) http://jakarta.apache.org/commons/httpclient/apidocs/org/apache/commons/httpclient/methods/multipart/MultipartRequestEntity.html Decide on one of the two. You can't mix a multipart request entity with parameters added directly to the PostMethod. hope that helps, Roland --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
