Konstantin Kolinko wrote: > but to fix the second one there, I need to generate JSP code that > coerces the string value to the expected type according to EL coercion > rules. > > I do not see how to easily implement that. Maybe somebody has an idea?
Some thoughts in-line. > 1) EL coercion rules are best implemented by > o.a.el.lang.ELSupport.coerceToType(obj, type), > but as far as I understand catalina.policy, a JSP page is not allowed > to call that class. Correct. > Either a wrapper method should be added (where?), or the policy be changed. > > JspRuntimeLibrary.convert(String,String,Class,Class) in package > o.a.jasper.runtime > looks similar to what is needed, but actually it is wrong: > when converting to a Boolean value it interprets "on" as true, but > according to EL rules that should be false (as Boolean.valueOf("on") > is false). > I think that it serves some other purpose. The only place I see that code being used is in o.a.j.c.Generator. I am pretty sure than is a bug that needs to be fixed. It has been like that since the very first Tomcat 3.0.x code import but I can't see any good reason in the specs for converting "on" to true. > Generator.GenerateVisitor.convertString(Class, String, String, Class, > boolean) in package o.a.jasper.compiler does conversion at compile > time, not at run time. I won't like to reimplement all those > conversion rules. +1 :) > 2) Alternative way: > > The comment in Generator.attributeValueWithEL() says that this method > is needed to prevent unescaping of literals that are outside of EL > expressions, as blindly passing them over to EL processor will result > in unescaping. > > Maybe we can double-escape those literals, so that when EL processor > performs their unescaping it will restore their original values? > If so, we can create one composite EL expression and pass it over to > EL processor, and it will evaluate it and perform all necessary > coercions. > > Is this a plausible route to resolve this? I looked at this when I worked on the EL Parser issues. If memory serves me correctly this had issues around correctly handling unescaped sequences like '\$', '\\$', '\\\$' etc. You may have better luck than I did. > What escaping is meant there? Is it \$, \#, \', \" ? You'll also need to escape \. Overall, I think a solution based on JspRuntimeLibrary.convert(String,String,Class,Class) is the way to go. That said, you are the one doing the work so feel free to ignore me ;) Mark --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org