Queiros
Queiros

Reputation: 1

Tomcat 7 with UTF-8 encode

Case 1: I have a virtual machine with Ubuntu and Tomcat 7.x. If i POST data with special characters to the server i'ts ok. I have a filter that run before any servlet and set the encode to UTF-8 request.setCharacterEncoding("utf-8");

Case 2: In the same virtual machine i have other Tomcat 7.x installation (reply). Now i installed the JOSSO 1.8.6 on Tomcat 7.x. After this when i try to submit POST data with special characters the servlet don't decode correctly request.getParameter("reportText");.

I believe that the JOSSO have any filter that run before my Encode Filter and uses the request what makes my filter request.setCharacterEncoding("utf-8") useless.

What i try to resolve the problem:

The POST request is generated by client JSP

<form id="xx" name="xx" onsubmit="return validateAndSubmitForm(this);" action="submitReport.do" method="post" enctype="application/x-www-form-urlencoded; charset: utf-8;"> xxx </form>

My JSP tag on top:

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

POST headers: image with the headers

Any ideas? Thank you.

Upvotes: 0

Views: 4308

Answers (2)

Jorge Santos Neill
Jorge Santos Neill

Reputation: 1785

The solution that work for me is add URIEncoding to server.xml file into of ubuntu configuration.

<Connector URIEncoding="UTF-8" connectionTimeout="20000" port="8082" protocol="HTTP/1.1" redirectPort="8443"/>    
<Connector URIEncoding="UTF-8" port="8009" protocol="AJP/1.3" redirectPort="8443"/>

Upvotes: 1

Jorge Santos
Jorge Santos

Reputation: 414

I added the URIEncoding attribute of the Connector element of the server.xml file which is the configuration file of tomcat.

My code is the following.

<Connector URIEncoding="UTF-8" connectionTimeout="20000" port="8082" protocol="HTTP/1.1" redirectPort="8443"/>    
<Connector URIEncoding="UTF-8" port="8009" protocol="AJP/1.3" redirectPort="8443"/>

Upvotes: 2

Related Questions