I have a jsp containing a form which posts to a servlet, when the servlet receives the parameters from the form the pound sign (£) is preceded with the following character Â. So £ becomes £. What is causing this and how can I get round it?
+2
A:
This sounds a lot like a character encoding issue. The response containing the pound sign is being sent in the UTF-8 character set, but is being interpreted in a different character set (probably ISO-8859-1).
Check what character encoding you are specifying for your JSP, and if the problem still persists, use a sniffer to investigate the response that the form posts, and specifically any character set it specifies. By default the form should use the same character set as the page it was served on, so you should be able to control it by checking the page's character set.
Andrzej Doyle
2009-01-14 22:15:42
It'll be sent as UTF-8 and read as ISO-8859-1, which may be the default codepage on the server. Make sure to use a single encoding for all JSP pages (<%@page pageEncoding) and form reading (request.setCharacterEncoding) for consistency - UTF-8 is almost always best.
bobince
2009-01-15 00:48:12
Ah of course - my mistake! Thanks for pointing out that discrepancy, I've edited the post accordingly.
Andrzej Doyle
2009-01-15 01:58:46
Yes the JSP is using UTF-8 as I have this line at the head of the page; <%@page contentType="text/html" pageEncoding="UTF-8"%>..So do I now have to use request.SetCharacter() encoding in the servlet to specify I want to read in UTF-8?
Deano
2009-01-17 12:41:06