5

Is there a difference between org.apache.commons.lang.StringEscapeUtils.escapeHtml and org.apache.commons.lang3.StringEscapeUtils.escapeHtml4 ?

mathematician
  • 1,942
  • 5
  • 19
  • 22

2 Answers2

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
1

Note that StringEscapeUtils.escapeHtml() has issues with apostrophes

fmpdmb
  • 1,370
  • 3
  • 21
  • 34