Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Additional Ascii char 'Â' added in JSP request

I am facing the same issue in tomcat & jsp as listed in below asp issue Classic ASP gremlims, getting a  inserted into text whenever an HTML special character is used

Using tomcat 5 and jsp. When I type in a string containing like ±20°C and submit to another JSP the resultant parameter after submit is ±20°C. An addition character 'Â' is being added before every special char in the request itself. How do I resolve this issue?

Thanks,

like image 354
ravi2082 Avatar asked Dec 18 '25 23:12

ravi2082


2 Answers

This is caused by displaying UTF-8 page as Latin-1. For example, ± is encoded as 0xB1 in Latin-1 but 0xC2, 0xB1 in UTF-8. 0xC2 happens to be Â.

This is kind of strange for a JSP page. Normally, JSP will use the same encoding in the writer and "Content-Type" header so you always get the same encoding. Check if you specifies encoding like this,

<%@page pageEncoding="UTF-8" %>

If you have a custom "Content-Type" header, make sure you append ", charset=UTF-8".

like image 102
ZZ Coder Avatar answered Dec 20 '25 12:12

ZZ Coder


That is the symptom of ISO-Latin-whatever source data being transcoded into UTF-8 on the way out. Check your character encodings.

like image 24
Steve Gilham Avatar answered Dec 20 '25 13:12

Steve Gilham



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!