PDA

View Full Version : why does everybody use c:out tag ........???


cujigar1
Aug 28th, 2005, 03:37 AM
<spring:bind path="command.password">

<input type="text" name="<c:out value="${status.expression}"/>"
value="<c:out value="${status.value}"/>"/>

</spring:bind>


when they can directly and easily use EL


<spring:bind path="command.emailAddress">
<input type="text" name="${status.expression}/>"
value="${status.value}"/>
</spring:bind>


note: i m referring to unnecessary usage of c:out tag

i just want to know that does using c:out has any advantage because all the examples in this world use it.

Sharebear
Aug 28th, 2005, 01:55 PM
Anyone feel free to correct me on this one, but I believe that the second version only works if you are using a container that supports the Servlet API 2.4 therfore only people using the "latest and greatest" containers can take advantage of this format.

HTH

Jon

sethladd
Aug 28th, 2005, 04:25 PM
That is correct. In fact, it's not enough to be inside a Servlet 2.4 container. Your webapp must declare itself as 2.4, via it's doctype in the web.xml.

cujigar1
Aug 28th, 2005, 06:47 PM
thanks for replying. now i know.

gmatthews
Aug 28th, 2005, 08:35 PM
I also seem to remember we had trouble with <c:out> when it came to internationlization, and that <spring:message> was better.

sethladd
Aug 29th, 2005, 02:08 PM
Yes, c:out does not perform i18n. You can also use the fmt:message tag to perform translations. The fmt tag also has other formatting tags, for numbers and dates, to help with i18n.

ojs
Dec 22nd, 2006, 12:04 PM
That is correct. In fact, it's not enough to be inside a Servlet 2.4 container. Your webapp must declare itself as 2.4, via it's doctype in the web.xml.

Isn't the c:out also useful for getting a cross-side-scripting safe html encoded output?

robcos
Dec 23rd, 2006, 06:14 PM
The main reason to use c:out is that it escapes the given value according the xml rules.
Take a look at http://www.oreillynet.com/cs/user/view/cs_msg/32734 för example.