I have a JSP page retrieving data and when single or double quotes are in the text they are displayed as this symbol .
JSP Code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>General</title>
</head>
<body>
<h1> <%= order.getDescription %> </h1>
</body>
</html>
Example: An order's description should look like this,
"20 - 4" x 6" widgets"
but I am getting this,
"20 - 4 x 6 widgets"
NOTE: I can not make modifications to the database.
[ EDIT ]
I used the commons-lang-2.4.jar to escape the characters and these are the primary characters giving me trouble:
- ‘ ->
- ’ ->
- “ ->
- ” ->
- – ->
I am sure other characters in the some format would give me issues, however, I just did a replace on the characters for a temporary fix and I am currently testing the suggestions below.
[ CODE FOR SOLUTION ]
This probably not the best way to do it but it got the job done. The code below is in the backing bean after the the data is retrieved from the database.
description = StringEscapeUtils.escapeHtml(description);
description = description.replaceAll("‘", """);
description = description.replaceAll("’", """);
description = description.replaceAll("“", """);
description = description.replaceAll("”", """);
description = description.replaceAll("–", "-");
description = StringEscapeUtils.unescapeHtml(description);