Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > JSTL - Variable not retrieving value

Reply
Thread Tools

JSTL - Variable not retrieving value

 
 
jill
Guest
Posts: n/a
 
      04-25-2007
I have declared a variable rowcolor. If i use cut that works. So
following two line of code is worknig.

<c:set var="rowColor" value="even" scope="page"/>
<tr class="<cut value='${rowColor}'/>">

But when i use below coe it does not work.
<tr class="${rowColor}">
HTML spits out <tr class="${rowColor}"> as this
where as in cut version it spits out <tr class="even">

Can any body pls tell me why <tr class="${rowColor}"> is not working.

 
Reply With Quote
 
 
 
 
Lew
Guest
Posts: n/a
 
      04-25-2007
jill wrote:
> I have declared a variable rowcolor. If i use cut that works. So
> following two line of code is worknig.
>
> <c:set var="rowColor" value="even" scope="page"/>
> <tr class="<cut value='${rowColor}'/>">
>
> But when i use below coe it does not work.
> <tr class="${rowColor}">
> HTML spits out <tr class="${rowColor}"> as this
> where as in cut version it spits out <tr class="even">
>
> Can any body pls tell me why <tr class="${rowColor}"> is not working.


Repeating the question doesn't encourage people to answer.
Repeating the question doesn't encourage people to answer.

From your first posting of this question, in "JSTL - $variablename not working",

jill wrote:
>> Please let me know why below code is ot worknig and how to solve it.
>>
>> <c:choose>
>> <c:when test='${(status.index)%2 eq 0}'>
>> <c:set var="rowColor" value="even" scope="page"/>
>> </c:when>
>> </c:choose>
>>
>> <tr class="${rowColor}">
>>
>> I get "${rowcolor}" in html for above line of code -- <tr class="$
>> {rowColor}">


Lew wrote:
> I doubt it very much. I would believe you got "${rowColor}", though.


> How is var="rowColor" set when the c:when condition fails?
>
> Your question would be easier for us to approach if you posted an SSCCE.
>
> You might be working with a version of JEE that only accepts EL in JSTL
> constructs. Since <tr> is not a JSTL tag, it wouldn't parse the EL
> expression in that scenario.
>
> Compare
> <p>${rowColor}</p>
> <p><cut value="${rowColor}"/></p>
>
> in a test page (which you could post as an SSCCE). What do you get?
>
> What is your platform?


Just out of curiosity, why did you start a new thread on the same question?

--
Lew
 
Reply With Quote
 
 
 
 
jill
Guest
Posts: n/a
 
      05-01-2007
On Apr 25, 9:30 am, Lew <(E-Mail Removed)> wrote:
> jillwrote:
> > I have declared a variable rowcolor. If i use cut that works. So
> > following two line of code is worknig.

>
> > <c:set var="rowColor" value="even" scope="page"/>
> > <tr class="<cut value='${rowColor}'/>">

>
> > But when i use below coe it does not work.
> > <tr class="${rowColor}">
> > HTML spits out <tr class="${rowColor}"> as this
> > where as in cut version it spits out <tr class="even">

>
> > Can any body pls tell me why <tr class="${rowColor}"> is not working.

>
> Repeating the question doesn't encourage people to answer.
> Repeating the question doesn't encourage people to answer.
>
> From your first posting of this question, in "JSTL- $variablename not working",
>
>
>
>
>
> jillwrote:
> >> Please let me know why below code is ot worknig and how to solve it.

>
> >> <c:choose>
> >> <c:when test='${(status.index)%2 eq 0}'>
> >> <c:set var="rowColor" value="even" scope="page"/>
> >> </c:when>
> >> </c:choose>

>
> >> <tr class="${rowColor}">

>
> >> I get "${rowcolor}" in html for above line of code -- <tr class="$
> >> {rowColor}">

> Lew wrote:
> > I doubt it very much. I would believe you got "${rowColor}", though.
> > How is var="rowColor" set when the c:when condition fails?

>
> > Your question would be easier for us to approach if you posted an SSCCE.

>
> > You might be working with a version of JEE that only accepts EL inJSTL
> > constructs. Since <tr> is not aJSTLtag, it wouldn't parse the EL
> > expression in that scenario.

>
> > Compare
> > <p>${rowColor}</p>
> > <p><cut value="${rowColor}"/></p>

>
> > in a test page (which you could post as an SSCCE). What do you get?

>
> > What is your platform?

>
> Just out of curiosity, why did you start a new thread on the same question?
>
> --
> Lew- Hide quoted text -
>
> - Show quoted text -


I started a new thread because I could not see my questions posted in
the group.

 
Reply With Quote
 
jill
Guest
Posts: n/a
 
      05-01-2007
On Apr 25, 9:30 am, Lew <(E-Mail Removed)> wrote:
> jillwrote:
> > I have declared a variable rowcolor. If i use cut that works. So
> > following two line of code is worknig.

>
> > <c:set var="rowColor" value="even" scope="page"/>
> > <tr class="<cut value='${rowColor}'/>">

>
> > But when i use below coe it does not work.
> > <tr class="${rowColor}">
> > HTML spits out <tr class="${rowColor}"> as this
> > where as in cut version it spits out <tr class="even">

>
> > Can any body pls tell me why <tr class="${rowColor}"> is not working.

>
> Repeating the question doesn't encourage people to answer.
> Repeating the question doesn't encourage people to answer.
>
> From your first posting of this question, in "JSTL- $variablename not working",
>
>
>
>
>
> jillwrote:
> >> Please let me know why below code is ot worknig and how to solve it.

>
> >> <c:choose>
> >> <c:when test='${(status.index)%2 eq 0}'>
> >> <c:set var="rowColor" value="even" scope="page"/>
> >> </c:when>
> >> </c:choose>

>
> >> <tr class="${rowColor}">

>
> >> I get "${rowcolor}" in html for above line of code -- <tr class="$
> >> {rowColor}">

> Lew wrote:
> > I doubt it very much. I would believe you got "${rowColor}", though.
> > How is var="rowColor" set when the c:when condition fails?

>
> > Your question would be easier for us to approach if you posted an SSCCE.

>
> > You might be working with a version of JEE that only accepts EL inJSTL
> > constructs. Since <tr> is not aJSTLtag, it wouldn't parse the EL
> > expression in that scenario.

>
> > Compare
> > <p>${rowColor}</p>
> > <p><cut value="${rowColor}"/></p>

>
> > in a test page (which you could post as an SSCCE). What do you get?

>
> > What is your platform?

>
> Just out of curiosity, why did you start a new thread on the same question?
>
> --
> Lew- Hide quoted text -
>
> - Show quoted text -


I get

${rowColor}

even

${rowColor}

odd

for following code -

<c:forEach var="list" items="${foundationAidBean.childInstitutions}"
varStatus="status">
<c:choose>
<c:when test='${(status.index)%2 eq 0}'>
<c:set var="rowColor" value="even" scope="page"/>
</c:when>
<ctherwise>
<c:set var="rowColor" value="odd" scope="page"/>
</ctherwise>
</c:choose>

<p>${rowColor}</p>
<p><cut value="${rowColor}"/></p>


</c:forEach>


So it looks my jree version is not correct.

j2se - 1.4.2
Oracle JDeveloper 10g

What version should I use for my El to work.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
JSTL: How do I set an array variable? Derek Mahar Java 2 06-07-2011 06:39 PM
(struts/JSTL) Setting bean property value with jstl choose compoundresults DaFoot Java 1 10-23-2008 12:42 PM
JSTL c:out not printing value jsguru72 Java 5 09-05-2008 01:47 AM
Custom JSTL that accepts JSTL expression Robert Mark Bram Java 0 12-15-2004 12:26 AM
jstl and c:out value not being evaluated Damian Sobieralski Java 3 06-01-2004 11:24 PM



Advertisments