JSP / JSTL with or without <c: out> tags
I help create a java jsp jstl web service, and all dynamic objects are inserted using ${object.foo} , and I was wondering if this actually changed in <c:out value="${object.foo} /> ?
the pages load correctly, but I wonder if there is something that I don’t see that might be the problem.
when you use the JSTL core out tag, you have a few more options:
- The values that you pass the tag will default to XML escaping
- You can specify the default value that will be displayed if the passed value is null.
Use EL expressions, and if you need output escaping, use the fn:escapeXml , such as ${fn:escapeXml(myText)} .
In previous versions of jsp, it was not possible to directly use el expressions in text content, you had to use c: out. This is no longer necessary, using el expressions directly for output creates a much less cluttered jsp, in my opinion. The c: out tag still uses it if you need to control the output escaping via the escapeXml attribute.