We're trying to move a website built mostly from JSPs from Websphere to Jetty. We're having a problem with NullPointerException
evaluating EL code in test
attributes:
<c:if test="${requestScope.domainSpecificName}">
The problem is that the domainSpecificName
attribute is either set to true or not present in the request.
In Websphere this line is compiled to
_jspx_th_c_if_0.setTest(((java.lang.Boolean) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${requestScope.domainSpecificName}", boolean.class, (PageContext)pageContext, _jspx_fnmap, false)).booleanValue());
(Note the class is boolean
and the default value is false
.)
The same line of the JSP, in Jetty, compiles to
_jspx_th_c_if_0.setTest(((java.lang.Boolean) org.apache.jasper.runtime.PageContextImpl.evaluateExpression("${requestScope.domainSpecificName}", java.lang.Boolean.class, (PageContext)_jspx_page_context, null)).booleanValue());
Here we have a class of Boolean
and a default value of null
, which obviously will throw a NPE if the attribute is not present.
From the documentation, it sounds like if we can set JexlBuilder.strict(false)
it will not treat null
values as errors. (Although I'm not sure how that would be compiled.)
Does anyone know how to configure JexlBuilder inside Jetty?
Alternatively, if I'm heading down the wrong path; does anyone know the correct way to be handling this? There are hundreds of instances of <c:if test="${...}">
that might throw NPEs, so at least in the short term fixing them all is not practical.