Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8343215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:59:21+00:00 2026-06-09T05:59:21+00:00

I have a simple Restlet service hosted on AppEngine. This performs basic CRUD operations

  • 0

I have a simple Restlet service hosted on AppEngine. This performs basic CRUD operations with strings and is working well with all sorts of UTF-8 characters when I test it with curl (for all the verbs).

This is consumed by a simple restlet client hosted in a servlet on another AppEngine app:

// set response type
resp.setContentType("application/json");
// Create the client resource
ClientResource resource = new ClientResource(Messages.SERVICE_URL + "myentity/id");
// Customize the referrer property
resource.setReferrerRef("myapp");
// Write the response
resource.get().write(resp.getWriter());

The above is pretty much all I have in the servlet. Very plain.

The servlet is invoked via jquery ajax, and the json that I get back is well formed and everything, but the problem is that UTF-8 encoded strings are coming back scrambled, for example:
Université de Montréal becomes Universit?? de Montr??al.

I tried adding this line in the servlet (before everything else):

resp.setCharacterEncoding("UTF-8");

But the only diference is that instead of getting ?? I get Universitᅢᄅ de Montrᅢᄅal (I don’t even know what kind of characters those are, asian I suppose).

I am 100% sure the restlet service is OK, because other than debugging it line by line I am able to test it from cmd line with curl and it’s returning well formed strings.

By looking at the http header of the response from firefox (when calling the servlet via javascript) I can see the encoding is indeed UTF-8, as expected. After hours of struggling reading every possible related article I came across this restlet discussion and noticed that indeed I do have Transfer-Encoding: chunked on the http header of the response. I tried the proposed solutions (override ClientResource.toRepresentation, didn’t do any good so I tried restlet 2.1 as susggested with ClientResource.setRe​questEntityBuffering​(true), no luck there either) but I am not convinced my issue is related to Transfer-Encoding: chunked at all.

At this point I am out of ideas, and I would really appreciate any suggestions! O_o

UPDATE:

I tried doing a manual GET with a classic UrlConnection and the string is coming back alright:

URL url = new URL(Messages.SERVICE_URL + "myentity/id");
URLConnection conn = url.openConnection();
InputStream is = conn.getInputStream();

StringWriter writer = new StringWriter();
IOUtils.copy(is, writer, "UTF-8");

resp.getWriter().print(writer.toString()); 

So much for being all RESTful and fancy …but still I have no clue why the original version doesn’t work! :/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T05:59:22+00:00Added an answer on June 9, 2026 at 5:59 am

    I tried doing a manual GET with a classic UrlConnection and the string is coming back alright:

    URL url = new URL(Messages.SERVICE_URL + "myentity/id");
    URLConnection conn = url.openConnection();
    InputStream is = conn.getInputStream();
    
    StringWriter writer = new StringWriter();
    IOUtils.copy(is, writer, "UTF-8");
    
    resp.getWriter().print(writer.toString());
    

    So much for being all RESTful and fancy …but still I have no clue why the original version doesn’t work! :/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have simple WCF Service Application (based on this tutorial : Getting Started ).
I have simple win32 application (not dialog box), and treeview in this application. All
I have simple php validation form that is halfway working. If you leave the
I have simple win service, that executes few tasks periodically. How should I pass
I have simple jQuery Mobile site created using asp.net mvc 2 and uses basic
i have simple side menu with this html code : <div id=menu> <div> Menu
I have simple user model: var user = Backbone.Model.extend({ initialize: function(){ this.bind(change:auth, function (){
Here is my .classpath file, after I have added two more external jars (org.restlet.ext.simple.jar
Have simple Spring Security webapp with password encoding: <security:authentication-manager alias=authenticationManager> <security:authentication-provider user-service-ref=personService> <security:password-encoder hash=md5
I have simple example: function File(name) { this.name = name this.text = null }

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.