I have the following code in my jsp scriptlet (inside <% %>):
boolean blockScreen = false;
if(title.equalsIgnoreCase(labelA) || title.equalsIgnoreCase(labelB))
{
blockScreen = true;
}
The java file generated corresponding to the above jsp contains following code(identical):
boolean blockScreen = false;
if(title.equalsIgnoreCase(labelA) || title.equalsIgnoreCase(labelB))
{
blockScreen = true;
}
But when I debug, I can not see the blockScreen variable. I decompiled the class file, and can see the following code:
if(!title.equalsIgnoreCase(labelA))
if(!title.equalsIgnoreCase(labelB));
Not sure why the blockScreen variable is getting cleaned out in the class file. The same variable is used further down in a c:choose tag:
<c:choose>
<c:when test="${blockScreen==true}">
<!--do something -->
</c:when>
<c:otherwise>
<!--do something else -->
</c:otherwise>
</c:choose>
I am using JBoss EAP 6 server.
Any help in this regard appreciated.
EL expression
${blockScreen==true}uses a request attribute namedblockScreen, not a scriptlet variable of the same name, therefore compiler is free to optimize away the usused variable.If you want to use a scriptlet variable instead, try
<c:when test="<%= blockScreen %>">.