Showing posts with label el. Show all posts
Showing posts with label el. Show all posts

Thursday, May 22, 2014

How to evaluate a scriptlet variable in EL?

So you want to evaluate a scriptlet variable in EL? Store it as a request attribute.
<%
    String var = "some";
    request.setAttribute("var", var);
%>

<c:if test="${param.variable1 == 'Add' && var == 'some'}">
However, this makes no sense. You should avoid scriptlets altogether and use JSTL/EL to prepare this variable. So if you make the functional requirement more clear, e.g. "How do I do this (insert scriptlet code snippet) using JSTL/EL?", then we'll be able to suggest the right approach.

See also:

Tuesday, May 13, 2014

Evaluate empty or null JSTL c tags

You can use the  or  for this.
 test="${empty var1}">
    var1 is empty or null.

 test="${not empty var1}">
    var1 is NOT empty or null.
or

     test="${empty var1}">
        var1 is empty or null.
    
    
        var1 is NOT empty or null.
    
The ${not empty var1} can also be done by ${!empty var1}.
To learn more about those ${} things (the Expression Language, which is a separate subject from JSTL),check here.