How to change character encoding to UTF-8

3,896 views
Skip to first unread message

lazi...@gmail.com

unread,
Apr 28, 2009, 10:33:24 AM4/28/09
to Google Web Toolkit
My question is how to change Character Encoding in requestBuilder. I
have managed so far to change Content-Type to "text/x-gwt-rpc" and I
can't change charset.

I have tried
RequestBuilder httpbuilder = new RequestBuilder(RequestBuilder.POST,
URL.encode(url));
httpbuilder.setHeader("content-Type", "text/x-gwt-rpc");

but now I don't know what header name is for character encoding

Please anybody help me

Thomas Broyer

unread,
Apr 29, 2009, 6:25:37 AM4/29/09
to Google Web Toolkit
httpbuilder.setHeader("content-Type", "text/x-gwt-rpc;
charset=utf-8");

(though i'm not sure what you're trying to do here...)

lazi...@gmail.com

unread,
Apr 29, 2009, 7:45:13 AM4/29/09
to Google Web Toolkit
I am trying to call ordinary servlet via spring (I am using gwt-sl
library and GWTHandler class) and requestbuilder in GWT (POST method).
When I am trying to do that without setting any header a get error:
1. Content-Type was 'text/plain; charset=utf-8'. Expected 'text/x-gwt-
rpc

so I am changing header Content-Type to text/x-gwt-rpc by
httpbuilder.setHeader("content-Type", "text/x-gwt-rpc");

but then I am get error :
2. Character Encoding is '(null)'. Expected 'charset=utf-8'

so I am trying like you suggest: httpbuilder.setHeader("content-Type",
"text/x-gwt-rpc; charset=utf-8");

but I get error:

3. encodedRequest cannot be empty

that is why I wanted to know header name for Character Encoding to be
not of the part content-type

but when I look closer to those errors numbers 1 and 2 comes from
com.google.gwt.user.server.rpc.RPCServletUtils
and number 3 from org.gwtwidgets.server.spring.GWTRPCServiceExporter
caused by com.google.gwt.user.server.rpc.RPC.decodeRequest

I am new at spring and GWT :)

Thomas Broyer

unread,
Apr 29, 2009, 10:08:52 AM4/29/09
to Google Web Toolkit


On 29 avr, 13:45, "lazins...@gmail.com" <lazins...@gmail.com> wrote:
> I am trying to call ordinary servlet via spring (I am using gwt-sl
> library and GWTHandler class) and requestbuilder in GWT (POST method).

AFAICT from the GWT-SL docs, GWTHandler is not an "ordinary servlet",
it is based on GWT-RPC; which means you should use GWT-RPC and not a
"plain old^^^low-level RequestBuilder".

An "ordinary servlet" would be called as you'd expect; GWT-RPC expects
a particular request payload (method arguments, serialized in GWT-RPC
special format, hence the Content-Type: text/x-gwt-rpc)

The GWT-SL docs are quite clear on how to write the client-side GWT
code to work with GWTHandler (i.e. GWT-RPC).

lazi...@gmail.com

unread,
Apr 29, 2009, 3:19:54 PM4/29/09
to Google Web Toolkit
You are right. I have mixed them all. Thanks for clarify. So right now
my problem is how to call servlet thru spring :) My application has
some servlets and I would like to call them via spring.

Thomas Broyer

unread,
Apr 29, 2009, 5:46:17 PM4/29/09
to Google Web Toolkit


On 29 avr, 21:19, "lazins...@gmail.com" <lazins...@gmail.com> wrote:
> You are right. I have mixed them all. Thanks for clarify. So right now
> my problem is how to call servlet thru spring :) My application has
> some servlets and I would like to call them via spring.

"via Spring" ?!

You mean having your servlets being "dependency injected" by Spring ?
If so, probably the Spring document will be enough, or the Spring
mailing list / user group / forum.
E.g. http://andykayley.blogspot.com/2008/06/how-to-inject-spring-beans-into.html

Otherwise, well, it's just a RequestBuilder. RequestBuilder is a low-
level API to make HTTP calls; if you understand HttpServlet's
HttpRequest/HttpResponse, then RequestBuilder shouldn't be hard to
comprehend too.
Reply all
Reply to author
Forward
0 new messages