• 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

string comparison with EL / JSTL

 
Ranch Hand
Posts: 618
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've just started trying to incorporate EL/JSTL into my coding, so bear with me, as I had trouble finding documentation on my problem. I have a List stored as a session attribute under the name "dates". For example:



I have a typical HTML select that dates is supposed to populate:



As you can see, when a date is chosen, the JavaScript submits the form and I handle it like this:



That already works. The only functionality I'm trying to add is to cause the option that was selected to be selected once the page comes back. I'm not sure how to do the String comparison between date and currentDate. Here's the message from the JasperException I get when I try to load the page:



When I try to change it to date.equals(currentDate) instead of date == currentDate, I get this message:



Thanks for any pointers...
[ August 11, 2005: Message edited by: Stephen Huey ]
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
>Attribute test invalid for tag otherwise according to TLD
In other words, the <c:otherwise> tag doesn't have an attribute called "test"
<c:otherwise> is meant to be the catchall at the bottom of a series of <c:when> statements. Like the "default" option for a case statement, or the final "else" at the end of an "if ... else if ... else if ... else...

Solution: remove the test attribute from the otherwise clause.

Question: Why are you testing ${country.continent == 'Africa'} anyway?
If you need an extra test, you need a new <c:if> or <c:when> clause.
[ August 11, 2005: Message edited by: Stefan Evans ]
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[Bear edit: removed answer that Stefan bet me to!]

P.S. When posting code, it's a good idea to check the 'disable smilies' checkbox.
[ August 11, 2005: Message edited by: Bear Bibeault ]
 
Stephen Huey
Ranch Hand
Posts: 618
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ha...yeah, I noticed that country.continent == 'Africa' and fixed it and I was too sleepy to remember at that point that I had just posted that on JavaRanch, but it wasn't the cause of the initial problem because it was breaking before that. Now you can probably find online where I got my sample code from!

Anyway, the otherwise bit makes total sense...I think I was thrown off by thinking the error was caused by an entirely different part of the code. It was near the end of the work day, and I was *pretty* tired!


Thanks!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic