The problem is resolved. We were trying to (1) read some POSTed data,
(2) converting it and then (3) POSTing it again.
setting the HttpServletRequest.setCharacterEncoding("UTF-8") before
(1) solved the issue.

But this brings us to two more questions.

1. Even when the setCharacterEncoding() was not set, the payload in
(1) has the encoding set to UTF-8 already. Why, then, was the encoding
not used by the app engine by default?

2. How does one set the default encoding for the jvm instance in app
engine?

Regards
Alok

On 19 अग, 15:33, आलोक (Alok) <alok.ku...@gmail.com> 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 google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to