tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Siegmar <oli...@siegmar.org>
Subject Re: Inconsistent output of Java 5 enums
Date Fri, 15 Oct 2010 05:40:40 GMT
Hi all,

Am Thursday 14 October 2010 schrieb Christopher Schultz:
> So I'm surprised that Oliver is getting that weird output.

I wrote in my initial mail to this list "I have an enum that has an overridden 
toString() method". I thought it was clear what that means, obviously it was 
not. Sorry for the confusion. So this is a simplified example for my enum:

public enum MyEnum {

    VALID(0),
    INVALID(1);

    private final int code;

    private MyEnum(int code) {
        this.code = code;
    }

    @Override
    public String toString() {
        return name() + " result, code: " + code;
    }

}


My JSP looks like this:

Output per EL: ${myEnumValue} <br/>
Output per JSTL: <c:out value="${myEnumValue}"/>


The output is:

Output per EL: VALID
Output per JSTL: VALID result, code 0


The thing is, that EL is using the name() method to print the enum and JSTL is 
using toString(). I did not expect a different enum treatment here.


One possible explaination is that Pid is right when he says "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". Does anyone know if a true JSTL 1.2 
using JSP 2.1 is available in the maven repository? Anyway I will try a 
manually downloaded version tonight.



Bye

Oliver


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message