tags:

views:

97

answers:

1

Hello, When I try to print a UTF-16 string in JSP, specifically Hebrew, it ends up showing up as HTML encoding (&#xxxx).

This problem occurs because I print an array of variables into the web page and then parse them. The variables are all UTF-16 strings, but once the servlet prints the variables, it becomes translated to HTML encoding. Is there any way to get rid of the encoding?

Thanks in advance

Edit for a bit more background:

The JSP that I'm printing is not the entirety of the page. It's used in a manner I don't quite understand by a server app which prints the JSPs output into its built in page. This isn't a frame or anything like that. It's just redirected output.

+1  A: 

See if adding

contentType="text/html; charset=UTF-8"

to the JSP header (<%@page ...) helps.

doublep
It didn't work. See my edit for a bit more clarification on the situation.
Ori Osherov
Also, I tried using UTF-16 instead of UTF-8 for the hell of it, but that completely botched everything up. I assume that wasn't meant to work.
Ori Osherov
@Ori: I'm not sure if UTF-16 is supported on the web at all. Presumably it is, but I never saw it used. Without details of how the page is generated it's hard to say more. Look what and where calls `setContentType()` on `HttpServletResponse` object, it might be "wrong" (not UTF-8) or missing. Also search for `setHeader()` call for `Content-Type` header — I'm not sure what of those takes precedence.
doublep
I'll look into it. Thank you for the help! +rep
Ori Osherov
No, character encodings has nothing to do with instantly converting non-ASCII characters to XML entities. A different character encoding would only cause the XML entities being numbered differently :)
BalusC
@BalusC: Isn't entity number the UCS codepoint? I.e. isn't it independent from encoding?
doublep