How can I escape special HTML characters in JSP?
Short answer:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:out value="${myString}"/>
there is another option:
<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
${fn:escapeXml(myString)}
How to encode a string to UTF8 and then display it correctly in html?
Try StringEscapeUtils to escape your String for html. This did a good job for me till now.
How to unescape HTML character entities in Java?
I have used the Apache Commons StringEscapeUtils.unescapeHtml4() for this:
Unescapes a string containing entity
escapes to a string containing the
actual Unicode characters
corresponding to the escapes. Supports
HTML 4.0 entities.
Related Topics
Inconsistent Performance Applying Foregroundactions in a Jeditorpane When Reading Html
How to Parse Xml Using the Sax Parser
Java Can't Connect to X11 Window Server Using 'Localhost:10.0' as the Value of the Display Variable
How to Read/Convert an Inputstream into a String in Java
Difference Between ≪? Super T≫ and ≪? Extends T≫ in Java
How to Handle Infinite Loop Caused by Invalid Input (Inputmismatchexception) Using Scanner
Why Is January Month 0 in Java Calendar
When Would You Use the Builder Pattern
Read/Write String From/To a File in Android
How to Get Current Location in Android
What Issues Should Be Considered When Overriding Equals and Hashcode in Java
Loading Resources Like Images While Running Project Distributed as Jar Archive
Infinite Recursion With Jackson Json and Hibernate JPA Issue