views:

96

answers:

1

I´m trying to take a string from a GET or POST parameter in JSP with some accents in UTF-8:

<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%
    request.setCharacterEncoding("UTF-8");
    String value = request.getParameter("q");
    out.print(value+" | aáa");
%>

The codification of the hardcoded string is correct but the codification of the value obtrained from the parameter (example: http://whatever/utf.jsp?q=a%E9a) it´s wrong.

I have already modify the the server.xml dropping the URIEnconding UTF-8. So I don´t now what I have to do to show the data in the correct format. Any idea?

+1  A: 

You need a%c3%a1a to represent an UTF-8 URL-encoded value of aáa.

Also check the outcome of java.net.URLEncoder#encode() and this online URL encoder.

BalusC