• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

c:out tag

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
Can anyone tell me how and why "<c ut>" jstl tag is used?

Regards,
Yashwanth
 
Ranch Hand
Posts: 284
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 java.io.Reader object, then it's coerced into a String and written in the JspWriter object.
  • If the evaluated value is a java.io.Reader, then data is read from the reader and then written to the JspWriter.


  • Hope this helps.
    [ March 14, 2006: Message edited by: Frederic Esnault ]
     
    reply
      Bookmark Topic Watch Topic
    • New Topic