Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any isset-like function in JSP?

I was wondering if we could check for all undefined and null variables in JSP using its built-in functions?

I know I can build a function to do that, but I need a lazy solution.

like image 865
cipher Avatar asked Aug 19 '12 06:08

cipher


1 Answers

<c:if test="${name == null}">variable name is undefined</c:if>

For testing you can define and undefine a variable using:

<c:set var="name" value="Petra"/>
<c:set var="name" value="${null}"/>

To state you are using the core JSTL tags add this to the top of the page:

<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
like image 56
Jano Avatar answered Oct 02 '22 12:10

Jano