java - How to make EL relational operators to work on Tomcat 8/JSTL 1.2 -


this question has answer here:

i'm having strange behavior since our upgrade tomcat 6 tomcat 8.0.32.

relational operators (<, >, <=, >=) not working variables defined c:set

public class serviceconstants {   public static final integer my_const = 15; } 

below code (updated):

<%@ page iselignored="false"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <c:set var="a" value="<%=serviceconstants.my_const%>"/> <c:set var="b" value="${127}" /> <html> <body> <br/>a: ${a} <br/>b: ${b} <br/>using variables {b > a}: ${b > a} <br/>using variables {b gt a}: ${b gt a} <br/>hardcoded values {127 > 15}: ${127 > 15} </body> </html> 

and below rendered

a: 15  b: 127  using variables {b > a}: false  using variables {b gt a}: false  hardcoded values {127 > 15}: true 

when comparing , b set c:set returning wrong answer.

below web.xml file

<?xml version="1.0" encoding="utf-8"?> <web-app xmlns="http://java.sun.com/xml/ns/javaee"   xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"   xsi:schemalocation="http://java.sun.com/xml/ns/javaee                   http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"   version="3.0" metadata-complete="true">    <absolute-ordering />    <distributable/>    <display-name>app name</display-name>    <jsp-config>     <taglib>       <taglib-uri>http://xyzo.org/app</taglib-uri>       <taglib-location>/web-inf/tld/app.tld</taglib-location>     </taglib>   </jsp-config> </web-app> 

i tried several solutions posted, changing tomcat 8.0.37 (latest), change web.xml file header , such.

any appreciated.

edit below:

i've found out numbers being interpreted strings el. if force cohersion works seems cumbersome.

<%@ page iselignored="false"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <c:set var="a" value="<%=serviceconstants.my_const%>"/> <c:set var="b" value="${127}" /> <html> <body> <br/>a: ${a} <br/>b: ${b} <br/>using variables {b > a}: ${b > a} <br/>using variables {b gt a}: ${b gt a} <br/>hardcoded values {127 > 15}: ${127 > 15} <br/>... <br/>forcing cohersion <br/>using variables {b > (0 + a)}: ${b > (0 + a)} </body> </html> 

it results:

a: 15  b: 127  using variables {b > a}: false  using variables {b gt a}: false  hardcoded values {127 > 15}: true  ... forcing cohersion  using variables {b > (0 + a)}: true 

any tips on how make el 'right thing' still appreciated.

if use expressions when setting variables it's less cumbersome:

<c:set var="a" value="${15}"/> <c:set var="b" value="${127}" /> 

Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -