title: Replace characters with HTML entities in Java
body: <p>I want to replace certain characters with their respective HTML entities in an HTML response inside a filter. Characters include <code>&lt;</code>, <code>&gt;</code>, <code>&amp;</code>. I can't use <code>replaceAll()</code> as it will replace all characters, even those that are part of HTML tags.</p>
  
  <p>What is the best approach for doing so?</p>