0

In my servlet I save to a String variable, a value which I get form a form (with POST) in my JSP page.This value sometimes isn't in English..

s1 = request.getParameter("Country");

Then to test, what I just read I print it to the log screen and I got $%^& when it isn't in English. I tried to add

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

in my jsp page and I also checked if there is this in the server.xml

URIEncoding="utf-8"

But It did't change anything.. What can i do?
EDIT
I added to my servlet the following

if (request.getCharacterEncoding() == null) {
            request.setCharacterEncoding("UTF-8");
        }

inside the protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

but i still have the problem

yaylitzis
  • 5,354
  • 17
  • 62
  • 107

1 Answers1

0

If you're using tomcat, you can try their utf8 encoding filter (add it to your web.xml of course). Their filter is called org.apache.catalina.filters.SetCharacterEncodingFilter, or if you don't want to depend on 3rd party then you can peek at their source code and write your own, it's not very complicated.

See also http://wiki.apache.org/tomcat/FAQ/CharacterEncoding

Pelit Mamani
  • 2,321
  • 2
  • 13
  • 11