I read a lot of similar question in the WEB but non of the solutions helped in my case. I implement web page with search, when the query can be Hebrew, English or any other language. When the user click "search" I use JavaScript to get the value in the field and show the result using Ajax. When user click "search" the JavaScript function sends a new request to my JSP file, when the query sent as a parameter.
Do you have any idea how to fix it?
The relevant lines in JavaScript:
...
request = new XMLHttpRequest();
var url = "SearchResults.jsp?userID=" + userID + "&query=" + encodeURIComponent(query);
alert("The query = " + query);
alert("The url = " + url);
request.open("GET", url, true);
...
The first alert shows the Hebrew correctly, the second alert show the url when the query parameter encoded with %%.. when I paste it into the Google search it writes the word in Hebrew correctly
The relevant lines in the server:
...
String userID = request.getParameter("userID");
FbLogger.fbLogger.info(request.getParameter("query"));
String query = URLDecoder.decode(request.getParameter("query"), "UTF-8");
FbLogger.fbLogger.info("Entered as Manager with Params: userID = " + userID + " , query = " + query);
...
I see the query as ×?שר×?×? in my log for the 2 messages above, the userID is passed correctly.
On each page I added:
<%@page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<meta http-equiv="Content-Type" content="text/html; charset=charset=UTF-8">
<script language="javascript" type="text/javascript" charset="utf-8" src="javascript/friendsSearch.js"></script>
I also changed the configuration in the Tomcat server (server.xml):
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
URIEncoding="UTF-8"/>