struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kris Schneider <k...@dotech.com>
Subject Re: AW: JSTL c:if question
Date Mon, 28 Feb 2005 23:38:00 GMT
Make sure to put the entire test within the EL expr delimiters:

<c:if test="${requestScope.mode == 'a'}">
  ...
</c:if>

The "scope" attribute is used when you also provide the "var" attribute to store
the result of the tested expression (it will be of type Boolean).

Quoting Günther Wieser <gwieser@creative-it.com>:

>  
> i think your test won't work as strings get compared using the equal method
> and not "==" (but i have no idea what the "test" attribute does in the tag
> class....).
> 
> if you use
> <logic:equals name="mode" value="a">whatever needs to be done</logic:equals>
> it should work (at least it works for me ;-) )
> 
> kr,
> guenther
> 
> -----Ursprüngliche Nachricht-----
> Von: David Johnson [mailto:chachany@gmail.com] 
> Gesendet: Dienstag, 01. März 2005 00:24
> An: Struts Users Mailing List
> Betreff: JSTL c:if question
> 
> a little off topic but..
> 
> I have a variable (a string named "mode") in request scope and I want to
> display something conditionally in the JSP. Right now, I have the following,
> which doesnt work. The error is
> 
> 2: Illegal scope attribute without var in "c:if" tag.
> 
> What am I doing wrong?
> 
> <c:if test="${mode}=='a'" scope="request">
>    first thing
> </c:if>
> <c:if test="${mode}=='b'" scope="request">
>    second thing
> </c:if>
> --
> -Dave
> ChaChaNY@Gmail.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 


-- 
Kris Schneider <mailto:kris@dotech.com>
D.O.Tech       <http://www.dotech.com/>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message