I did some testing myself just now with a simple enum and I think this is a Tomcat bug somewhere. Whether the old behaviour was right or wrong vs the new I don't know. I also think that your enum is screwy or doing something different then you think.
At any rate I created a simple enum public enum Fruit{APPLE,ORANGE,BANANA; public String toString(){ switch(this){ case APPLE: return "A is for Apple"; case ORANGE: return "O is for Orange"; default: return "B is for Banana"; } } } I then used the following in a JSP (enumtest is a simple model object with a Fruit property set to Fruit.APPLE) #1 = ${enumtest.fruit} <br> #2 = <c:out value="${enumtest.fruit}"/> On tomcat 5.5. I get #1 = A is for Apple #2 = A is for Apple On tomcat 6 I get #1 = APPLE #2 = A is for Apple Which is obviously not the same, and surprised me, but it seems if I understand this thread that it is the opposite of what you are seeing and that I really don't understand. -----Original Message----- From: Oliver Siegmar [mailto:oli...@siegmar.org] Sent: Friday, October 15, 2010 1:29 PM To: Tomcat Users List Subject: Re: Inconsistent output of Java 5 enums Hello, Am Friday 15 October 2010 schrieb Maximilian Stocker: > > > Or, just consistently use EL, since that actually works as you expect. > > > > +1 '<c:out' seems surplus. > > And how do you escape XML characters to entity codes using pure EL? > > This seems a valid reason except that is this a problem for your enum? As stated before, it was just a simplified example. > If it really is a problem then did you try and create a new getter method > that returns your to string content in the enum? And then call that with > c:out. The enum is part of a 3rd party lib. And of course, there are several workarounds available, but I want to understand what is happening here and clearify if it's a bug. And it's not just the c:out tag - it also happens with other Tags. For demonstration I've created a custom Tag: public class MyCustomTag implements Tag { public void setValue(String value) { System.out.println(value); } @Override public void setPageContext(PageContext pc) { } @Override public void setParent(Tag t) { } @Override public Tag getParent() { return null; } @Override public int doStartTag() throws JspException { return SKIP_BODY; } @Override public int doEndTag() throws JspException { return EVAL_PAGE; } @Override public void release() { } } My TLD: <?xml version="1.0" encoding="UTF-8" ?> <taglib xsi:schemaLocation="http://java.sun.com/xml/ns/javaee web- jsptaglibrary_2_1.xsd" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.1"> <tlibversion>1.0</tlibversion> <uri>http://my-domain.org/customLib</uri> <tag> <name>customTag</name> <tagclass>mypackage.MyCustomTag</tagclass> <bodycontent>empty</bodycontent> <attribute> <name>value</name> <required>true</required> <rtexprvalue>true</rtexprvalue> </attribute> </tag> </taglib> And in my JSP file is use it: <%...@taglib prefix="myLib" uri="http://my-domain.org/customLib"%> <myLib:customTag value="${myEnum}"/> <myLib:customTag value="foo.${myEnum}.bar"/> I would expect, that this outputs: VALID foo.VALID.bar The output in catalina.out is very interesting: VALID foo.VALID result, code 0.bar Remember, VALID is the enum name() and "VALID result, code 0" is the enum toString(). I think that is REALLY weird... Bye Oliver --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org