When sending an AJAX request in UTF8 to a server that uses REST, any part that contains non-English characters is disregarded.
I am working with Java on the server side with REST, and the client sends AJAX requests in UTF8 that may include Hebrew words.
Here is an example of the AJAX request:
var clientNumber = '12344432432';
var userID = '321321321';
var someHebrewWord = ...;
var someEnglishWord = ....;
var servletUrl = '/Management/services/manager/' + clientNumber + '/' + userID + '/' + someEnglishWord + '/' someHebrewWord;
alert('Sending this :' + servletUrl);
$.ajax({
url: servletUrl,
type: 'POST',
cache: false,
data: { },
success: function(data){
alert('Return value is:' + data);
window.location = "./replyPage.html";
}
, error: function(jqXHR, textStatus, err){
alert('text status '+textStatus+', err '+err + " " + JSON.stringify(jqXHR));
}
});
On the server side, I implement REST as follows:
@Produces({ "application/json" })
@Path("/manager")
public class Management {
@POST
@Path("{clientNumber}/{userID}/{someEnglishWord}/{someHebrewWord}")
@Produces("application/json")
public boolean insert(@PathParam("clientNumber") String clientNumber, @PathParam("userID") String userID,
@PathParam("someEnglishWord") String someEnglishWord, @PathParam("someHebrewWord") String someHebrewWord)
{
// perform some operation
}
@POST
@Path("{clientNumber}/{userID}/{someEnglishWord}")
@Produces("application/json")
public boolean updateSomething(@PathParam("clientNumber") String clientNumber, @PathParam("userID") String userID , @PathParam("someEnglishWord") String someEnglishWord)
{
// perform some other operation
}
// more code
}
Although I am sending 4 fields in the AJAX request, the updateSomething()
method is being invoked instead of insert()
.
Why is this happening and how can it be fixed?
Any help is greatly appreciated.