I"ve never used characters in the EL, and personally, I'd just make temp.value a single-character srting and be done with it. But you can grab the EL Specification -- it contains exhaustive rules for its type coersions.
Paul Clapham wrote:What I did when I ran into that problem was to convert the character ('H') into its Unicode code-point (72) and use that instead:
Cryptic? Obscure? Not self-documenting? Guilty on all counts, but it works. But I'm never going to write a Java bean which returns a char ever again. One-character strings are much better.
Woops....I'm not sure I understood your reply.
In my situation, the character is coming from the database. I can't convert it there. There's an Oracle column with a single H or L in it and Hibernate is returning the character to me in the application.
I did your test above and it "worked", that is, it displayed a a single row of data, but I'm not sure that's all I needed to do. I'm not sure what you meant by "converting" the 'H' character. Did you just mean doing the comparison as you showed it above (implicit conversion)?
Mike London wrote:I'm not sure what you meant by "converting" the 'H' character. Did you just mean doing the comparison as you showed it above (implicit conversion)?
Sorry, I meant me (the programmer) hunting down an ASCII chart on the internet, finding that 'H' was represented by 72 in ASCII (and hence in Unicode), and changing my (i.e. your) EL code to use 72 instead of 'H'. So then yeah, future programmers are going to look at that and say "72? What?" (or words to that effect). Code comments would help here.
Bear Bibeault wrote:I would still convert the character to a string before sending it to the JSP page.
For me that would require rewriting my bean's method to return String rather than char. Which wouldn't have been that hard, but it wasn't something I wanted to mess with while converting to EL. It sounds like Mike's beans are being automatically generated by Hibernate, or something like that, but I would definitely recommend not working with chars in EL if you can avoid it.
If it's a Hibernate entity, then I would add an @Tranisent getter that returns it in String format just for the EL. This is a tactic I've used before when what makes Hibernate happy isn't suitable for EL consumption.
subject: How to test for a character in a JSTL "test"