1

I am trying to get parameter in my java class that contain a special character. I have added it as follows

   <%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%> 

I have these two parameters: (1)3 –days System Admin (6EE SP1) training at VMware Bangalore location (2)Daiichi:eDossier – Phase1 new_6500004691

After submitting the page i get the perfect result,but two parameter names gets change as below:

(1)Daiichi:eDossier ââ¬â Phase1 new_6500004691 (1)3 âdays System Admin (6EE SP1) training at VMware Bangalore

Please suggest

nakul
  • 1,445
  • 7
  • 20
  • 30

2 Answers2

4

Try setting request.setCharacterEncoding("UTF-8") before the first call to getParameter().

If that doesn't work, have a look at your Tomcat config.

Community
  • 1
  • 1
ChristopheD
  • 112,638
  • 29
  • 165
  • 179
  • `request.setCharacterEncoding()` won't work since it `Overrides the name of the character encoding used in the body of this request.` and not in parameters. – Buhake Sindi Jun 05 '12 at 10:41
  • The documentation states: `This method must be called prior to reading request parameters or reading input using getReader(). Otherwise, it has no effect.` The parameters are part of the body ;-) http://docs.oracle.com/javaee/5/api/javax/servlet/ServletRequest.html#setCharacterEncoding%28java.lang.String%29 – ChristopheD Jun 05 '12 at 10:44
  • It's however not clear if the OP is talking about GET or POST parameters. – BalusC Jun 05 '12 at 13:52
2

I know what's your problem: Your application server/servlet container is not configured to support unicode characters.

You will have to configure you application server/servlet container to support UTF Encoding. Tomcat Example has been answered in this SO question.

Another alternative is to write a Character Encoding Filter and configure it in your web application.

Community
  • 1
  • 1
Buhake Sindi
  • 87,898
  • 29
  • 167
  • 228