• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

string comparison with EL / JSTL

 
Stephen Huey
Ranch Hand
Posts: 618
  • Mark post as helpful
  • send pies
  • 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 ]
 
Stefan Evans
Bartender
Posts: 1780
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
>Attribute test invalid for tag otherwise according to TLD
In other words, the <ctherwise> tag doesn't have an attribute called "test"
<ctherwise> 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 ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65122
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic