On 14/10/2010 20:31, Christopher Schultz wrote: > All, > > On 10/14/2010 3:24 PM, Christopher Schultz wrote: >> Pid, > >> On 10/14/2010 3:21 PM, Pid wrote: >>> On 14/10/2010 20:03, Oliver Siegmar wrote: >>>> Hi Pid, >>>> >>>> Am Thursday 14 October 2010 schrieb Pid: >>>>> Which JSTL implementation are you using and which Java version was it >>>>> compiled for/on? >>>> >>>> http://repo2.maven.org/maven2/javax/servlet/jstl/1.2/jstl-1.2.jar >>>> >>>> Using Sun/Oracle Java 6u21 > >>> OK. > >>> The related sources jar was built in 2006, and the pom for that >>> indicates that it's dependent on JSP 2.0, rather than 2.1. > >>> At a guess, JSTL doesn't know what an enum is, so it's just doing what >>> it would do for any other unknown Object subclass, and is calling the >>> .toString() method. > >> Something I didn't bother asking: what does the default Enum.toString >> return? > > Answer to my own question: > > public class EnumTest > { > public enum Weekday { > SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY > } > > public static void main(String[] args) > { > System.out.println(Weekday.SUNDAY); > } > } > > This produces "SUNDAY" as output. > > The EnumTest.Weekday "class" doesn't override the toString method, > allowing java.lang.Enum (it's superclass) to handle that. > > java.lang.Enum.toString is implemented like this: > > public String toString() > { > return name; > } > > ... and "name" is a String which is initialized in the constructor (when > I decompile EnumTest.Weekday, I can see it uses the string "Sunday", as > one might expect). > > So I'm surprised that Oliver is getting that weird output.
He's overriden the .toString method, no? EL must be recognising it's an Enum and treating it differently. There's a spec for that, so it'll probably define what to do with an Enum. p --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
0x62590808.asc
Description: application/pgp-keys
signature.asc
Description: OpenPGP digital signature