struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject RE: JSTL c:if question
Date Tue, 01 Mar 2005 12:18:06 GMT

In order to specify the scope, you preceed your variable with the scope
type.  Therefore for a request-scope variable, the variable would be :
"requestScope.variable".  There are several scope types:


Additionally, when you have multiple c:if tags that test different
conditions of the same variable, I would suggest rewriting the block as

  <c:when test="${requestScope.mode=='a'}">
    first thing
  <c:when test="${requestScope.mode=='b'}">
    second thing
    a catch all section

Consider the above more like a switch or if/elseif combo rather than
multiple if statements.

Hope this helps.

-----Original Message-----
From: David Johnson [] 
Sent: Monday, February 28, 2005 6:24 PM
To: Struts Users Mailing List
Subject: 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 test="${mode}=='b'" scope="request">
   second thing

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message