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

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: