Why do I get NullPointerExceptions in my JSP when upgrading from Glassfish 3 to 4?

I upgraded from Glassfish 3 to 4 and now my JSPs drop NPE. I have not changed the code, so this should be the difference in Glassfish. JSP that looked like this:

<c:when test="${invoke}">

Now gives me NPE if I don't change it to the following:

<c:when test="${not empty invoke && invoke}">

I wonder why this change is necessary. Can someone tell me what caused this? Why did he work before and no longer work?

+4
source share
2 answers

3, -, JEE7, . , , , EL 3.0 2.2. , , . , Glassfish. boolean boolean .

null - ( String) null s. , a null, boolean, a null, a null, boolean false.

, NPE s, . , , .

+1

< > Glassfish 4, NPE (wannabe) EL- :

<c:if test="${couldNotExistVar}">

couldNotExistVar:

  • -
  • ...

JSP + JSTL + EL:

<c:if test="${ obj.someExpensiveCalculation }">
    <c:set var="couldNotExistVar" value="true" scope="request" />
</c:if>

:

<c:set var="imSureExistsVar" value="false" scope="request" />
<c:if test="${ obj.someExpensiveCalculation }">
    <c:set var="imSureExistsVar" value="true" scope="request" />
</c:if>

  • .

, NPE , ( Java EE), Glassfish 4. p >

+1

Source: https://habr.com/ru/post/1531212/


All Articles