• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

c:if

 
Ranch Hand
Posts: 517
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can we have something other than EL expression inside the c:if tag?

Like this,

<c:if test="true">
Inside if.
</c:if>

or

<c:if test="10 > 5">
inside if
</c:if>

Thanks
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The string inside the "test" attribute will be evaluated as a java.lang.Boolean, using the Boolean(String) constuctor.

So, test="true" will return true, because Boolean("true") will be instanciated. And according to the API:
Boolean(String):
Allocates a Boolean object representing the value true if the string argument is not null and is equal, ignoring case, to the string "true". Otherwise, allocate a Boolean object representing the value false. Examples:

So, test="5 < 6" will not be true. Because Boolean("5 < 6") instanciated a Boolean object set to false.
 
MInu
Ranch Hand
Posts: 517
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<c:if test="true">
Inside if.
</c:if>

//The output is Inside if

<c:if test="false">
Inside if.
</c:if>


//The output is Inside if


Why it is so?..please clarify this.

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

I think you hava not inserted the taglib directive to declare the taglib identified the prefix "c", so the action elements are ignored. and the page is printing the text.

add <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> at top of JSP or any library uri you are using.

Thanks
 
MInu
Ranch Hand
Posts: 517
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes Narendra,it was a mistake from my side.

Thanks for correcting me....
 
There were millions of the little blood suckers. But thanks to this tiny ad, I wasn't bitten once.
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic