Reputation:
I have a web application running on Tomcat5. In a jsp page say page1.jsp, there are some check boxes, where title and value have some french characters (Français). When I select some of the check boxes and submit the page, it goes to page2.jsp where I am showing selected titles. Problem is, on this page the special characters are getting change (Français). This is happening when form's method is "POST". In case of "GET", it works fine. In Tomcat's server.xml, the uriEncoding is defined as "UTF-8". I have gone through so many posts but the problem is remain.
Upvotes: 3
Views: 3517
Reputation: 9793
You may want to take a look at the answer here: UTF-8 and Servlets on Tomcat/Linux
Upvotes: 0
Reputation: 75456
Looks like mixed encoding is used. Please make following changes,
<Connector>
in server.xml have URIEncoding="UTF-8". Just make this change and try your GET. It's good if it breaks :)<%@page pageEncoding="UTF-8" contentType="text/html;charset=utf-8" %>
request.setCharacterEncoding("UTF-8")
to all your servlets. You might have to do this in a filter if you have other filters because this only has effect before parameters are processed.Upvotes: 1
Reputation: 6928
I did a test. You need to add accept-charset to the form tag:
<form ... accept-charset="UTF-8" ...>
... and tell the container what encoding to use before reading any parameters, because the browser won't send the encoding it used in a header:
request.setCharacterEncoding("UTF-8");
Finally, make sure the encoding of the page you output is set in both the response header and a meta tag in the head
.
Upvotes: 1