This week's book giveaway is in the Spring forum.
We're giving away four copies of Modern frontends with htmx and have Wim Deblauwe on-line!
See this thread for details.
Win a copy of Modern frontends with htmx this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JSTL when test problem

 
Rancher
Posts: 1449
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Below is a code snippet from a JSP I have. I want the background colors of the rows in a table to alternate. I can make this work in scriptlet code fine but the when test below is returning false every time so that instead of alternating colors a single background color (specified by the otherwise tag) is displayed.

I'm assuming expression in the test is incorrect or I should be using a different form to represent the test but I'm not sure what that form would be.
Thanks,
 
John Wetherbie
Rancher
Posts: 1449
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also tried this...

but it does not appear to work either.
I'm very puzzled.
 
John Wetherbie
Rancher
Posts: 1449
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just an update...
The

seems to be working fine now. Not sure why it wasn't working yesterday. Maybe Tomcat was having a problem.
If the code above SHOULDN'T work please let me know.
Thanks,
 
Author
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by John Wetherbie:
Just an update...
The

seems to be working fine now. Not sure why it wasn't working yesterday. Maybe Tomcat was having a problem.
If the code above SHOULDN'T work please let me know.
Thanks,


This latter code should work. The code you tried first shouldn't work as such, since you can't use rtexprvalues without also using the "RT" version of JSTL taglibs. That is, you'd have to import the "c_rt" tag library, and say
<c_rt:when test="<%= ... %>">
In general, I recommend using the expression language ("${ ... }"), as your second example does.
 
John Wetherbie
Rancher
Posts: 1449
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, Shawn.
Like I said, Tomcat must have been having a problem. Everything works fine now. Weird.
 
The only thing that kept the leeches off of me was this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic