Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSTL when test problem

 
John Wetherbie
Rancher
Posts: 1449
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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,
 
Shawn Bayern
Author
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thanks, Shawn.
Like I said, Tomcat must have been having a problem. Everything works fine now. Weird.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic