David,
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:
pageScope
requestScope
sessionScope
applicationScope
Additionally, when you have multiple c:if tags that test different
conditions of the same variable, I would suggest rewriting the block as
follows:
<c:choose>
<c:when test="${requestScope.mode=='a'}">
first thing
</c:when>
<c:when test="${requestScope.mode=='b'}">
second thing
</c:when>
<c:otherwise>
a catch all section
</c:otherwise>
</c:choose>
Consider the above more like a switch or if/elseif combo rather than
multiple if statements.
Hope this helps.
Chris
-----Original Message-----
From: David Johnson [mailto:[EMAIL PROTECTED]
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>
<c:if test="${mode}=='b'" scope="request">
second thing
</c:if>
--
-Dave
[EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]