From my JSP, I am sending a GET request with a parameter called jobDetails which contains some Chinese characters [encoded with URLEncoder.encode()]. Now in the doGET() of my servlet, I need to write the data to a file. When I do
request.getParameter("jobDetails"); // this one retrieves wrong characters
There is a solution for this setting the URIEncoding="UTF-8"
in
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443"/>
tag of Tomcat but our architect is hell bend on not to change the existing tomcat settings. I tried with setting a filter for setting the characterEncoding() for request inside doFilter() as mentioned in BalusC's blog. But this one works for POST requests only. Is there any other solution to this other than changing the Tomcat settings ? I am using Tomcat 6 and jdk 1.6.
I found a way somehow... I imported org.springframework.web.bind.ServletRequestUtils
class from org.springframework.web-3.0.0.RELEASE.jar and used the following for parsing the parameter 'jobDetails' from 'request' object:
String jobDetails = new String((ServletRequestUtils.getStringParameter(request, "jobDetails")).getBytes("ISO-8859-1"), "UTF-8");