Great, thanks for all the help. I'll try it out - I'm sure one (or more)
of the suggestion will help.

I assume in the example below, just like I can have a 'pageScope' there can
also be 'sessionScope', 'requestScope' and 'applicationScope'?


>-- Oorspronkelijk bericht --
>Reply-To: "Tag Libraries Users List" <[EMAIL PROTECTED]>
>Date: Mon, 21 Jul 2003 06:44:02 -0700
>From: "K.C. Baltz" <[EMAIL PROTECTED]>
>To: Tag Libraries Users List <[EMAIL PROTECTED]>
>Subject: Re: JSTL question: how to use variables in <c:if> and <c:set>
>
>
>All the JSTL tags use EL ("Expression Language") which generally looks 
like ${ ... }.  All of the variables referenced in EL are in some sort 
of scope, (page, request, session, application).  That scope is handled 
by HashMaps (E.g. request.getAtt
>ibute()  what's used for requestScope 
variables). 

Scriptlets and tags that take scriptlets in their attributes use RT 
Expressions (RunTime?).  A variable named in a scriptlet is simply a 
local variable to the servlet that is generated for the
>JSP.  In order 
to access an RT Expr variable from JSTL scripts, you need to stuff the 
the RT variable into one of those HashMaps.  So:

<%
    int i = 5;

    pageContext.setAttribute( "i", new Integer(i) );  // doesn't have to

be "i"
%>


><c:if test="${row.ID == pageScope.i} >

</c:if>


Charl Gerber wrote:

>Hi,
>
>I have a question. How can I use variables declared in other pieces of java
>code withing my JSP within a <c:if> piece of code?
>
>example:
>
><%
>  int i = 5
>
>  * now to a sql call with sql tags and get some results *
>  <c:if test="${row.ID == i}">
>    etc.
>%>
>
>I cannot get that row.ID == i to work. Also tried <%= i %>, but that causes
>casting exceptions.
>
>Alternatively, how can I make SQL
>results available to other pieces of Java.
>At the moment I do a <c:set> and then the other code gets the variable from
>the scope it was set to, but it seems a bit tedious... is there a shorter
>way?
>
>Thanks!
>
>Charl
>
>
>----------------
>----------------------------------------------------
>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]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to