This example will show how to escape HTML characters using java, guava, apache commons and springframework.
Setup
Straight up Java
Google Guava
Guava HtmlEscapers will escapes HTML meta characters as specified by HTML 4.01.
Spring Framework
Using springframework's HtmlUtils.htmlEscape will escape HTML character references based on HTML 4.01 recommendation.
Apache Commons
This snippet will escape html special characters in a java string with apache commons.