Possible Duplicate:
Recommended method for escaping HTML in Java
Replace characters with HTML entities in java
I have some java code which writes text including angle-brackets to a DB; this text is displayed on a web-page.
Rather than change my java code to be full of entity codes, I wondered if I can keep the constants like “<test>” and use a standard library function to generate the entity-based string “<test>“?
If you just want to do angle brackets, I’d have a look at Java’s String Replace functionality.
But you probably should take a look at StringEscapeUtils if you want a more complete solution
in particular, public static String escapeHtml(String str) looks like a promising function
Judging by that signature, I would guess that
is the way to use it.