Hi Micky,
What _do_ you get at the server via Reader/InputStream?
I get "null" via Reader/InputStream.
That is interesting, considering your sample code below.
Here are part codes of the client side and server side I used for experimenting.
---- client code ----
// ... lots of construction
StringEntity stringEntity = new StringEntity(login, HTTP.UTF_8); // login is an xml content
// let's see what is being sent
System.out.println("posting the following string: " + login);
stringEntity.setContentType(" text/plain; charset=UTF-8");
httpPost.setEntity(stringEntity);
httpclient.execute(httpPost);
This fragment of your client side code looks correct.
I'm just wondering about the value of login. Have you
tried sending a hard-coded string instead?
...StringEntity("<?xml version='1.0' encoding='UTF-8'?><empty/>", HTTP.UTF_8);
---- server code ----
// ... lots of construction
//build reader to read input buffer
BufferedReader reader = request.getReader();
StringBuffer buffer = new StringBuffer();
int c ;
while( (c = reader.read()) != -1){
buffer.append( (char)c );
}
reader.close();
System.out.println("receive: " + buffer.toString());
----
The buffer.toString() is null.
Now that is interesting. If the reader were null, you'd get
a NullPointerException in the while() loop. If the buffer
was empty, you'd see "receive: " without a null. The return
value of buffer.toString is never null. If you are seeing
"receive: null", then you are actually sending the string
"null" in your POST request to the server.
See the comments above: check the string you are sending.
cheers,
Roland
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]