currently I use org.apache.commons.lang.StringEscapeUtils escapeHtml() to escape unwanted HTML tags in my Strings but then I realized it escapes characters with
org.apache.commons.lang.StringEscapeUtils escapeHtml()
If you're using Wicket, use:
import org.apache.wicket.util.string.Strings; ... CharSequence cs = Strings.escapeMarkup(src); String str = Strings.escapeMarkup(src).toString();