Reputation: 3319
I have a forma variable ftDtClo defined in form like,
public String getFtDtClo () {
String dateStr = "";
if(this.getCse().getDtClo()!=null) {
dStr = DtUtil.formatDate(this.getCse().getgetDtClo(), DtUtil.FORMAT_MM_DD_YYYY_KK_MM_SS);
}
return dateStr;
}
In JSP the code looks like,
<c:choose>
<c:when test="${not empty cseList.ftDtClo}">
<c:out value="${cseList.ftDtClo}"/>
</c:when>
</c:choose>
But i get the foll exception,
wrapped exception:
javax.servlet.jsp.JspException: javax.servlet.jsp.JspException: An error occurred while evaluating custom action attribute "test" with value "${not empty cseList.ftDtClo}": An error occurred while getting property "ftDtClo" from an instance of class abc.cseDetailLists (java.lang.NullPointerException)
at org.apache.taglibs.standard.tag.common.core.ImportSupport.acquireString(ImportSupport.java:306)
at org.apache.taglibs.standard.tag.common.core.ImportSupport.doEndTag(ImportSupport.java:161)
Im assuming not empty will take care of null check. Am i missing something? any i/p is highly appreciated.
Upvotes: 3
Views: 50668
Reputation: 11579
Try to change this:
public String getFtDtClo () {
String dateStr = "";
if(this.getCse()!=null && this.getCse().getDtClo()!=null) {
dStr = DtUtil.formatDate(this.getCse().getDtClo(), DtUtil.FORMAT_MM_DD_YYYY_KK_MM_SS);
}
return dateStr;
}
If it does not work, check your function DtUtil.formatDate
as well.
Upvotes: 1
Reputation: 40318
<c:choose>
<c:if test=${cseList != null}>
<c:when test="${not empty cseList.ftDtClo}">
<c:out value="${cseList.ftDtClo}"/>
</c:when>
</c:if>
</c:choose>
Upvotes: 4