Jason Bourne
Jason Bourne

Reputation: 786

UTF-8 Encoding in JSP & Tomcat

I am working in jsp based application running on tomcat 7.0.50

The jsp are saved in utf-8 and every jsp has

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv = "Content-Type" content = "text/html; charset=utf-8" />

I configured Tomcat connectors encoding to UTF-8

        <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" 
               URIEncoding="UTF-8" />

In the bin/catalina.bat, I added the param:

set JAVA_OPTS=%JAVA_OPTS% -Dfile.encoding=UTF-8

But when I try to check the passed params in the http post from the form, i found that "Français" is passed as "Français".

How to resolve this and force the http post encoding to utf-8? What is wrong with the config I am making?

Upvotes: 1

Views: 415

Answers (1)

Jason Bourne
Jason Bourne

Reputation: 786

I found the solution for this issue, before dealing with the request paramters, just insert:

request.setCharacterEncoding("UTF-8");

And every thing will be ok

Link where I found the solution

Upvotes: 1

Related Questions