1

I have the following scenario:

JSP -> Servlet -> ServiceAPI -> Service Servlet

I enter some cyrilic symbols in the JSP page, which is the start of the scenario. On the next step, the Servlet, I read the data from the JSP in UTF-8. So for, so good. Everything is OK.

Then I pass the data to a ServiceAPI, which sends it to a Service Servlet. Here comes the problem. The data in the Service Servlet is read as '??????'. So, I guess the problem is in the Service API which does not send the data correctly. ServiceAPI implementation uses Apache Http Client to send the data to the Service Servlet.

As I read in Apache Http Client documentation (http://hc.apache.org/httpclient-3.x/preference-api.html#HTTP_method_parameters) there is a way to set a character encoding in the request. But I am not able to apply this, becuase of a the following error: "Access restriction: The method setParameter(String, Object) from the type HttpParams is not accessible due to restriction on required library ...". So I am kind of stuck. Do you have any idea if the problem is really in Apache Http Client and I how can I fix it.

Thanks in advance.

rashid.rashidov
  • 105
  • 1
  • 8
  • Which HC version exactly are you using? You mentioned 3.x in your question, but you tagged 4.x. This is confusing. Those versions are very different. – BalusC Sep 04 '12 at 11:46

1 Answers1

-1

To correctly implement Character Encoding in web apps consists of 4 steps

1.First you have to configure your web server.

2.Then you have to force your web app to use UTF-8 encoding for all requests/responses.

3.Third you have to use JSP page encoding.

4.And last you must use HMTL-meta tags.

In your case the problem lies most probably on step 2 IMO

Here is the perfect article for you How to get UTF-8 working in Java webapps? that describes how to do all these extensively

Community
  • 1
  • 1
MaVRoSCy
  • 17,747
  • 15
  • 82
  • 125
  • This doesn't answer OP's concrete problem at all. This only answers the JSP-Servlet part, not the Servlet-HttpClient part. – BalusC Sep 04 '12 at 11:44