tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Affan Qureshi" <quere...@etilize.com>
Subject Re: Accessing page local variables using JSTL
Date Wed, 07 May 2003 12:18:07 GMT
Thanks for your reply. I understand the difference between the scoped and
scripting variable. I want to know how do u access "scripting" variable in
JSTL, if at all?

Thanks

Affan

----- Original Message -----
From: "Pierre Delisle" <Pierre.Delisle@Sun.COM>
To: "Tag Libraries Users List" <taglibs-user@jakarta.apache.org>
Sent: Wednesday, May 07, 2003 4:26 AM
Subject: Re: Accessing page local variables using JSTL


> Hi Affan,
>
> > How do I access local variables using JSTL <c:if>, <c:out> tags.
> >
> > Example:
> > <% boolean someFlag = getFlagValue(); %>
>
> In the above code, 'someFlag' is a *scripting* variable,
> not to be confused with a *scoped* variable.
>
> A scripting variable is accessed within Java scriptlets, as in
> <% if (someFlag) { %>
>    ...
> <% } %>
>
> A scoped variable is directly accessible via the EL as in:
>
> <c:if test="${someFlag}">
>    ...
> </c:if>
>
> >
> > <c:if test="${someFlag}">
> >     ...... do this .....
> > </c:if>
> >
> > This doesn't work unless i do pageContext.setAttribute("someFlag", new
> > Boolean(someFlag));
>
> That's because ${someFlag} refers to a scoped variable, not a
> scripting variable. In your example, someFlag is a scripting variable.
> 'pageContext.setAttribute()' makes it a scoped variable in 'page' scope.
>
> I'd suggest you take a look at the spec (http://java.sun.com/jstl),
> or get a good book on JSTL (many are available). This will help you get
> up to speed quickly with the basic concepts involved in JSTL.
>
>     -- Pierre
>
> >
> > Thanks,
> >
> > Affan
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>


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


Mime
View raw message