On 14/10/2010 20:31, Christopher Schultz wrote:
> All,
>=20
> On 10/14/2010 3:24 PM, Christopher Schultz wrote:
>> Pid,
>=20
>> 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
>=20
>>> OK.
>=20
>>> 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.
>=20
>>> At a guess, JSTL doesn't know what an enum is, so it's just doing wha=
t
>>> it would do for any other unknown Object subclass, and is calling the=
>>> .toString() method.
>=20
>> Something I didn't bother asking: what does the default Enum.toString
>> return?
>=20
> Answer to my own question:
>=20
> public class EnumTest
> {
> public enum Weekday {
> SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY
> }
>=20
> public static void main(String[] args)
> {
> System.out.println(Weekday.SUNDAY);
> }
> }
>=20
> This produces "SUNDAY" as output.
>=20
> The EnumTest.Weekday "class" doesn't override the toString method,
> allowing java.lang.Enum (it's superclass) to handle that.
>=20
> java.lang.Enum.toString is implemented like this:
>=20
> public String toString()
> {
> return name;
> }
>=20
> ... and "name" is a String which is initialized in the constructor (whe=
n
> I decompile EnumTest.Weekday, I can see it uses the string "Sunday", as=
> one might expect).
>=20
> 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=
=2E
p
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
|