Is there a difference between org.apache.commons.lang.StringEscapeUtils.escapeHtml and org.apache.commons.lang3.StringEscapeUtils.escapeHtml4 ?
Asked
Active
Viewed 8,955 times
2 Answers
5
they come from different packages in fact
escapeHtml comes from org.commons.lang (lang 2.5 API) and let's you use a writer object. It can also escape string from an SQL source
escapeHtml4 is from org.commons.lang3 (lang 3.1 API) is specialy use to escape character from a HTML4 source. Nothing more, nothing less
They do the same job but i would recommend using "escapeHtml4" since its from a newer package
See : EscapeHtml4 and escapehtml

P.Nichols
- 193
- 1
- 2
- 9
-
I can see that they come from different packages.. my concern is if escapeHtml4 is backwards compatible... – mathematician Feb 28 '13 at 17:09
1
Note that StringEscapeUtils.escapeHtml()
has issues with apostrophes

fmpdmb
- 1,370
- 3
- 21
- 34
-
In other words: do not use it for putting text into HTML documents. – David Balažic Sep 20 '18 at 10:33