1

Given a JSP page, and some object bound to a request attribute called "foo", I can refer to "foo" with:

${foo}

If the value of "foo" has a bean property called, say, "type", and the type of "type" is some enum class, then to make comparisons I would use a string:

<c:if test='${foo.type == "WHATEVER"}'>

Then assuming that one of the constants in my enum class has the name "WHATEVER", that comparison should work, and produce either true or false.

Now what I'm wondering is how exactly that comparison is supposed to be carried out by the servlet container. Some Oracle documentation (here) suggests (vaguely) that what happens is that the string constant is converted to the enum type, and then the comparison is made.

I'm investigating a situation involving code that I think works differently between Jetty/Tomcat (ie, Apache) and Resin. The Apache world seems to be doing the right thing, or at least the thing that I'd expect according to that documentation from Oracle.

What I fear is that another property of my enum may be causing the Resin implementation to do something different. Specifically, my enum class has a .toString() implementation that returns a different string than that returned by .name(). That quirk causes no problems in an Apache server, or at least none that I've ever seen. If Resin implements the comparison by converting the enum constant to a string (via .toString(), not .name()) instead of converting the string to the enum type, then things won't work consistently.

Note that in all other respects I'm having no issues with using my enum types (lots of them are like this) in various other ways in JSP/JSTL/EL. There are in fact only a small number of places where there's EL logic in the JSP, because the application does most of its work via client-side template rendering.

edit — I'm pretty sure I confirmed that Resin does the comparisons differently, though I don't know exactly what that is. I have (for reasons I don't recall) a "name" EL function in my own EL function library, so I can use that to work around the problem.

Pointy
  • 405,095
  • 59
  • 585
  • 614
  • Have you tried to make sure the name() value is what is being used for the string comparison [assuming that it's the toString() quirk that's hanging you up]? – alfreema Jul 03 '15 at 20:26
  • @alfreema yes, but my own Jetty (7.6.15; that's the newest one that I can get to work with a regular `.war` file) doesn't support that. My own EL function however does work around the problem. – Pointy Jul 03 '15 at 23:22

1 Answers1

1

Unfortunately Resin is processing incorrectly. I've filed a bug at http://bugs.caucho.com/view.php?id=5925

Incarnate1970th
  • 202
  • 2
  • 7
  • Thanks; that's what I suspected. I've had other "interesting" type conversion issues with the EL in Resin before. – Pointy Jul 03 '15 at 23:22