How to set Unicode in Google app-engine?

181 views
Skip to first unread message

Hung Ha

unread,
Jan 15, 2016, 11:29:45 AM1/15/16
to Google App Engine

I am building my app in Google App Engine

Ok, here I got a Servlet

public void doPost(HttpServletRequest req, HttpServletResponse resp)
        throws IOException {
     String firstName=req.getParameter("firstName");
     System.out.println(URLDecoder.decode(firstName, "UTF-8")+" "+ firstName);
  }

Now, I sent "Thủy" to the Servlet and it shows this output

th?y th?y

Then, I set up appengine-web.xml

<appengine-web-app>.......
 <env-variables>
    <env-var name="DEFAULT_ENCODING" value="UTF-8" />
  </env-variables>

</appengine-web-app>

Then when running i got this error:

com.google.appengine.tools.development.EnvironmentVariableChecker$IncorrectEnvironmentVariableException: One or more environment variables have been configured in appengine-web.xml that have missing or different values in your local environment. We recommend you use system properties instead, but if you are interacting with legacy code that requires specific environment variables to have specific values, please set these environment variables in your environment before running.
[Mismatch environmentVariableName=DEFAULT_ENCODING environmentVariableValue=null appEngineWebXmlValue=UTF-8 appEngineWebXmlFile=C:\Users\henry\workspace8\FluentEnglish\war\WEB-INF\appengine-web.xml]
    at com.google.appengine.tools.development.EnvironmentVariableChecker.check(EnvironmentVariableChecker.java:75)
    at com.google.appengine.tools.development.ApplicationConfigurationManager.checkEnvironmentVariables(ApplicationConfigurationManager.java:240)
    at com.google.appengine.tools.development.ApplicationConfigurationManager.access$000(ApplicationConfigurationManager.java:32)
    at com.google.appengine.tools.development.ApplicationConfigurationManager$WarModuleConfigurationHandle.checkEnvironmentVariables(ApplicationConfigurationManager.java:394)
    at com.google.appengine.tools.development.JettyContainerService.connectContainer(JettyContainerService.java:211)
    at com.google.appengine.tools.development.AbstractContainerService.createConnection(AbstractContainerService.java:273)
    at com.google.appengine.tools.development.AbstractInstanceHolder.createConnection(AbstractInstanceHolder.java:37)
    at com.google.appengine.tools.development.AbstractModule.createConnection(AbstractModule.java:73)

So, what's wrong?

Why doesn't HttpServletRequest show Unicode Text?

How to make HttpServletRequest show Unicode Text?

Nick (Cloud Platform Support)

unread,
Jan 15, 2016, 4:54:46 PM1/15/16
to Google App Engine
System.out.println will print to the default logger. Unless you are viewing the logs in a context which supports unicode, you might see the '?' char. This is my guess as to the first issue. As to the second issue of the error, if you read the error text, it seems to suggest that you are running into the problem of not setting the environment variable in your environment as well as in appengine-web.xml, as this doc says they should be set when running dev-server.
Reply all
Reply to author
Forward
0 new messages