JSP : JSTL's <c:out> tag

Steve Kuo picture Steve Kuo · Nov 14, 2008 · Viewed 223.9k times · Source

Writing a JSP page, what exactly does the <c:out> do? I've noticed that the following both has the same result:

<p>The person's name is <c:out value="${person.name}" /></p>
<p>The person's name is ${person.name}</p>

Answer

krosenvold picture krosenvold · Nov 14, 2008

c:out escapes HTML characters so that you can avoid cross-site scripting.

if person.name = <script>alert("Yo")</script>

the script will be executed in the second case, but not when using c:out