I have HTML code that I store in a Java.lang.String variable. I write this variable to a file and set the encoding to UTF-8 when writing the contents of the string variable to a file in the file system. I open this file and everything looks great, for example. → displayed as a right arrow.
However, if the same line (containing the same content) is used by the jsp page to display content in the browser, characters like → are displayed as a question mark (?)
When storing the contents in a String variable, I'm sure I use:
String myStr = new String(bytes[], charset)
instead of just:
String myStr = "<html><head/><body>→</body></html>";
Can someone please tell me why the contents of String are written perfectly to the file system but not displayed in jsp / browser?
Thanks.