As Victor said, <pre>
does not avoid this, you may be thinking that this tag is converting content to entities, but maybe it's just a mess.
I personally allow the exact recording of what was "written", but at the time of reading I use methods similar to htmlspecialchars
, thus avoiding conflicts, since the texts did not change the recording.
If your concern is to read the data from a bank and print it on the screen, you can use it when reading the data from the line:
import org.apache.commons.lang.StringEscapeUtils;
...
String data = StringEscapeUtils.escapeHtml("<script>alert(1);</script>");
I do not know how your code is, and what framework you use, but I believe that the meaning is always this, to "escape" content at the time of viewing (correct me if I'm wrong).
Documentation: StringEscapeUtils (Commons Lang 2.6 API)