JSTL - Variable not retrieving value

Discussion in 'Java' started by jill, Apr 25, 2007.

  1. jill

    jill Guest

    I have declared a variable rowcolor. If i use c:eek:ut that works. So
    following two line of code is worknig.

    <c:set var="rowColor" value="even" scope="page"/>
    <tr class="<c:eek:ut 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 c:eek:ut version it spits out <tr class="even">

    Can any body pls tell me why <tr class="${rowColor}"> is not working.
     
    jill, Apr 25, 2007
    #1
    1. Advertising

  2. jill

    Lew Guest

    jill wrote:
    > I have declared a variable rowcolor. If i use c:eek:ut that works. So
    > following two line of code is worknig.
    >
    > <c:set var="rowColor" value="even" scope="page"/>
    > <tr class="<c:eek:ut 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 c:eek:ut 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><c:eek:ut 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
     
    Lew, Apr 25, 2007
    #2
    1. Advertising

  3. jill

    jill Guest

    On Apr 25, 9:30 am, Lew <> wrote:
    > jillwrote:
    > > I have declared a variable rowcolor. If i use c:eek:ut that works. So
    > > following two line of code is worknig.

    >
    > > <c:set var="rowColor" value="even" scope="page"/>
    > > <tr class="<c:eek:ut 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 c:eek:ut 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><c:eek:ut 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.
     
    jill, May 1, 2007
    #3
  4. jill

    jill Guest

    On Apr 25, 9:30 am, Lew <> wrote:
    > jillwrote:
    > > I have declared a variable rowcolor. If i use c:eek:ut that works. So
    > > following two line of code is worknig.

    >
    > > <c:set var="rowColor" value="even" scope="page"/>
    > > <tr class="<c:eek:ut 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 c:eek:ut 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><c:eek:ut 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>
    <c:eek:therwise>
    <c:set var="rowColor" value="odd" scope="page"/>
    </c:eek:therwise>
    </c:choose>

    <p>${rowColor}</p>
    <p><c:eek:ut 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.
     
    jill, May 1, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Derek Mahar
    Replies:
    2
    Views:
    39,986
    DoggieDaddy
    Jun 7, 2011
  2. Damian Sobieralski

    jstl and c:out value not being evaluated

    Damian Sobieralski, May 28, 2004, in forum: Java
    Replies:
    3
    Views:
    11,442
    Damian Sobieralski
    Jun 2, 2004
  3. Robert Mark Bram

    Custom JSTL that accepts JSTL expression

    Robert Mark Bram, Dec 15, 2004, in forum: Java
    Replies:
    0
    Views:
    976
    Robert Mark Bram
    Dec 15, 2004
  4. jsguru72

    JSTL c:out not printing value

    jsguru72, Sep 4, 2008, in forum: Java
    Replies:
    5
    Views:
    2,364
    Arne Vajhøj
    Sep 5, 2008
  5. DaFoot
    Replies:
    1
    Views:
    1,701
    DaFoot
    Oct 23, 2008
Loading...

Share This Page