markosca
markosca

Reputation: 136

I can't send a request by Firefox in iso-8859-1

I have an application in Java EE and I have my database in ISO-8859-1, thus I need do the jsp encoding in ISO-8859-1... (all my pages are in iso-8859-1)

I have a jsp with a javascript code, which does a request to a Struts action.

This is my js code.

$.ajax({
    type:'GET',
    encoding:'iso-8859-1',      
    contentType: 'text/html;charset=ISO-8859-1',
    url: xUrl,
    success: function(){
        $("#MensajeOk").attr('style','display:block');
        $("#MensajeOk").delay(10000).slideUp(1000);
    }
});

with IE and Chrome all is correct, because it does the request coding in ISO-8859-1 but Firefox encodes the request in UTF-8 and this is a problem for me, because in server side I need ISO-8859-1 and with FF there are some characters than i can't recover.

mi form is

<html:form action="/action.do" acceptCharset="iso-8859-1"> 
<input type="text" name="title">

and my java code is

new String((request.getParameter("title")+"").getBytes("iso-8859-1"),"iso-8859-1"));

with it, I can recover fine the text with IE and Chome, but fails with Firefox.

Other option will be send the request in UTF-8 encoding by encodeURI('data') but in the server side I can't convert the text from UTF-8 to ISO-8859-1...

Some idea???

Thanks a lot and sorry for me english!!

Upvotes: 1

Views: 839

Answers (1)

oezi
oezi

Reputation: 51797

looking at the documentation, there doesn't seem to be an option called encoding - but theres a nice little hint (including the solution to your problem) on the contentType-option:

Data will always be transmitted to the server using UTF-8 charset; you must decode this appropriately on the server side.

so it seems like firefox is right and the other browsers do it wrong - try to remove the encoding-option and to a serverside conversion.

Upvotes: 1

Related Questions