0

i am using java application and i want to set encoding to UTF-8 using :

     request.setCharacterEncoding("UTF-8");

the problem is with the request it is not defined ?!

Matt Ball
  • 354,903
  • 100
  • 647
  • 710
lara
  • 1
  • 2
    More code, please. The `request` variable is not defined? `setCharacterEncoding()` is not a method of your `request` object? What is `request`? Where did it come from? Your question is not answerable in its current state. – Matt Ball Jan 25 '11 at 19:58

3 Answers3

0

This must be set prior to reading request parameters or reading input; therefore if you are doing it after the fact it will have no effect.

In addition if you are using Tomcat you should also set the URIEncoding to UTF-8 within your connectors as noted in this SO answer.

Community
  • 1
  • 1
Aaron McIver
  • 24,527
  • 5
  • 59
  • 88
0

Do you want to specify the response encoding? That's done via the ServletResponse.

response.setContentType("text/html;charset=utf-8"); 
Griff
  • 1,796
  • 3
  • 23
  • 48
0

the problem is with the request it is not defined ?!

By the time your request arrives on the server, it is already encoded in a specific format. You cannot change the request message's encoding at runtime. However you can change the way the encoding is interpreted at runtime using the serCharacterEncoding() method.

More info on encoding.

Deepak Bala
  • 11,095
  • 2
  • 38
  • 49