Escaping HTML in Java

Today I was looking around for ways to escape HTML in java, similar to htmlspecialchars() in PHP.

I found this Lang package: http://commons.apache.org/lang/

To use it:

1. Download the jar file and put it with other libraries in lib

2. Import “org.apache.commons.lang.StringEscapeUtils;”

3. StringEscapeUtils.escapeHtml(myString);

API/Documentation can be found here: http://commons.apache.org/lang/api-release/index.html