On 31/05/17 23:31, Chris Cheshire wrote:
> I am using tomcat 7 on CentOS 7 and I need to pass a null value to tag
> attributes of type Long/Integer/Float, however it is *always* coerced to
> zero.
> 
> <%@attribute name="parentId" required="true" rtexprvalue="true"
> type="java.lang.Long" %>
> 
> Changing required to false does nothing. I tried setting the system
> property org.apache.el.parser.COERCE_TO_ZERO to false in tomcat.conf
> (-Dorg.apache.el.parser.COERCE_TO_ZERO=false with my other JAVA_OPTS) but
> this does nothing.

As expected. That system property only affects evaluation of EL expressions.

> The value before it hits the tag is null and inside the
> tag is 0. If I query the System properties it shows it as set to false, but
> Tomcat is not honoring it and is still coercing nulls to zero. I understand
> the spec says to do this etc but that defeats the purpose of using an
> object vs atomic type in the first place and is horribly shortsighted>
> Upgrading to Tomcat 8 is not a solution unfortunately as there is no RPM
> for it.

I don't believe an upgrade would change the behaviour.

> How do I pass a null Long/Float/Integer as a tag attribute and have it kept
> as null and not turned into an incorrect value?

Use parentId="<%=null%>" rather than parentId=""

Ugly, but it does the job. Scriplets aren't coerced.

Mark

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

Reply via email to