Try

OutputStreamWriter w = new OutputStreamWriter(c.getOutputStream(),
"UTF-8");

On Aug 19, 12:33 pm, आलोक (Alok) <[email protected]> wrote:
> I am having trouble with sending out a POST request that contains
> UTF-8 data.
>
> Here's what I'm doing:
>
> ...
> 01                       String s = <some json object string
> containing non-ascii (devanagari) data>;
> 02                       URL u = new URL(<some valid url>);
> 03
> 04                       HttpURLConnection c = (HttpURLConnection)
> u.openConnection();
> 05                       c.setRequestProperty("Content-Type",
> "application/json; charset=UTF-8");
> 06                       c.setDoOutput(true);
> 07                       c.setRequestMethod("POST");
> 08                       OutputStreamWriter w = new
> OutputStreamWriter(c.getOutputStream());
> 09                       w.write(s);
> 10                       w.close();
> 11                       int r = c.getResponseCode();
> 12                       if(r == HttpURLConnection.HTTP_OK) {
> 13                               //SUCCESS
> 14                       }
> 15                       else {
> 16                              //FAILURE
> 17                       }
> ...
>
> Now, when I test this snippet via the development server (http://
> localhost:8888) the post data is written properly to the url u.
> However when I deploy this to the production server (http://
> myapp.appspot.com) the non-ascii data is converted to question marks
> (?).
>
> I understand that setting the Content-Type as above should be
> sufficient to dispatch the data to the url u.
> I could understand this to be a problem at the url u end if both the
> developement and production side behavior was the same. However that
> is not the case, the problem occurs only in the production server.
>
> Does anyone have a similar experience? Is there a setting in web.xml/
> appengine-web.xml that is missing?
>
> I could see a similar post 
> here:http://groups.google.com/group/google-appengine-java/browse_thread/th...
>
> I am not sure if the query was resolved, but that question mentions a
> difference in the behavior between development and production too.
>
> This is on GAE 1.3.5. I could upgrade to GAE 1.3.6 if that helps (I
> would upgrade today anyway and check if there is a difference in
> behavior but none is mentioned in the release notes.)
>
> Any pointers/workarounds would be appreciated.
>
> Regards
>
> Alok

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to