• 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 value="${param}"/> vs ${param}

 
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi folks,

What't the difference between this two statements <c:out value="${param}"/> and ${param}? Is not exactly the same if you don't use the scapeXml attribute? Is there any special reason to use the c tag?

Thanks in advance for your answers.
 
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<c: out> tag has one attribute i.e. default that is get printed to output if value spacified is null.
e.g.
suppose we are printing userName in to first page of appliation.
if user come from login then we put his/her name in session as "userName"
else we want to print guest.


then simply put,
<c: out value='${sessionScope. userName}' default='guest' />

if userName in session it will prints name of user else guest.

to do this by EL we need to if else condition for checking userName.
 
Albareto McKenzie
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I forgot completly about the default attribute. Thanks.
I asked this because in the application I am working I have seen several times things like <c:out value="${param}"/> that makes not to much sense for me if they are alone.

Thanks for your reply ;)
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The primary purpose of using <c:out> is to take advantage of the automatic HTML-encoding. It should be used for all non-trusted data.
 
Albareto McKenzie
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:The primary purpose of using <c:out> is to take advantage of the automatic HTML-encoding. It should be used for all non-trusted data.



Ok, thanks for your answer ;)
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic