It's not a secret anymore!
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes c:out       tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "c:out       tag" Watch "c:out       tag" New topic

c:out tag

yeshwanth reddy
Ranch Hand

Joined: Mar 10, 2006
Posts: 38
Hi all,
Can anyone tell me how and why "<c ut>" jstl tag is used?

Frederic Esnault
Ranch Hand

Joined: Feb 13, 2006
Posts: 284
Hi !

The c: out tag is used to display a value. It takes 3 parameters :
  • value (mandatory);
  • escapeXml (optional);
  • default (optional).

  • The defaultattribute holds the value to display if the value attribute holds a null value. Instead of using the default attribute, you may specify default value in the tag body (body-content : JSP).

    escapeXml attribute (which defaults to true) tells that if the value contains some XML special characters (< > & ' "), they are translated to entity code (ex: < translates to & lt; ). The result is that the special characters are displayed in the resulting page, instead of being interpreted as XML components. It also avoids malicious attacks where users would include tags in a text area that is interpreted when you want to display it, resulting in unwanted code executed on the server.

    Finally, the value attribute holds the value to display.

    All of these attributes can take dynamic values (rtexprvalue = true)

    Finally, value and default (or body content instead of default)deal with Objects, not only Strings. So :
  • If the evaluated value does not resolve to a object, then it's coerced into a String and written in the JspWriter object.
  • If the evaluated value is a, then data is read from the reader and then written to the JspWriter.

  • Hope this helps.
    [ March 14, 2006: Message edited by: Frederic Esnault ]

    SCJP 5 - SCWCD 1.4 - SCBCD 1.3 - Certification study documents/resources:
    I agree. Here's the link:
    subject: c:out tag
    It's not a secret anymore!