You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by Matt Raible <ma...@raibledesigns.com> on 2002/05/02 09:44:56 UTC
and testing for empty string in JSTL
I am trying to do the following:
<c:when test="${topicForm.image == ''}">
but it doesn't seem to work even when getImage() returns "".
I tried the keyword "empty" as well with no luck:
<c:when test="${topicForm.image == empty}">
Re: and testing for empty string in JSTL
Posted by Shawn Bayern <ba...@essentially.net>.
On Thu, 2 May 2002, Matt Raible wrote:
> I am trying to do the following:
>
> <c:when test="${topicForm.image == ''}">
>
> but it doesn't seem to work even when getImage() returns "".
This works in the general case. Consider the following example:
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%!
public static class FooBean {
public String getValue() { return ""; }
}
%>
<% pageContext.setAttribute("foo", new FooBean()); %>
<c:if test="${foo.value == ''}">
foo.value returned an empty string
</c:if>
Are you sure your topicForm.image property really equals ""?
> I tried the keyword "empty" as well with no luck:
>
> <c:when test="${topicForm.image == empty}">
The syntax is 'empty foo', not 'foo == empty'. As in:
<c:if test="${empty foo.value}">
foo.value is null, the empty string, or an empty collection
</c:if>
--
Shawn Bayern
"JSP Standard Tag Library" http://www.jstlbook.com
(coming this summer from Manning Publications)
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>