nakul
nakul

Reputation: 1473

Java handling special character in request.getParameter

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

Upvotes: 1

Views: 8192

Answers (2)

Buhake Sindi
Buhake Sindi

Reputation: 89169

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.

Upvotes: 2

ChristopheD
ChristopheD

Reputation: 116157

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

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

Upvotes: 4

Related Questions