I have this Web Application in JSP running on JBoss Application Server. I am using Servlets for friendly urls. I'm sending search parameters through my JSP's and Servlets. I am using a form with a text box, the Servlet
The first Servlet uses request.getParameter()
to get the text, and sends it to another Servlet with response.sendRedirect
(masking the URL to something "friendly"). This final Servlet uses request.getRequestDispatcher().forward()
to send the parameters to the JSP in the "ugly" way: searchResults.jsp?searchParameters=Parameters
.
Now, when the Search Results page is displayed, the URL displays the correct search term with "friendly url". Example: http://site.com/search/My-Search-Query
even when using special characters like: http://site.com/search/Busqué-tildes-y-eñies
. But when I try to use that search term in my JSP, the special characters are not displayed correctly.
The whole system uses i18n, and we've had no problems with special characters so far. But when the information is sent through the form (say from index.jsp to searchResults.jsp) special characters are not correctly displayed:
á - á
é - é
í - Ã
ó - ó
ú - ú
ñ - ñ
The whole code base is supposed to be in UTF-8, but apparently I'm missing something when passing the parameters. As I said, they are correctly displayed in the URL, but not inside the JSP.
I was thinking of converting those á
manually, but I guess there's a better way to do it correctly, using the correct encoding. Besides, there can be new characters later which I may not be aware of right now (French, Spanish, etc.)
Just in case, I'll let you know I have these lines on each JSP:
<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>