tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peter lin <peter....@labs.gte.com>
Subject Re: testing on empty string or null with jstl
Date Tue, 02 Apr 2002 15:22:39 GMT

according to the specs, I believe EL will evaulate null value to zero
length string.

if you treat zero length string and null as the same condition, does
that work for your situation? 

I'm a little confused by the example you provide. the first when checks
to make sure name and email are not null or zero length. the otherwise
is supposed to send an email. but who is it suppose to send it to? the
friend's email address?

if you use request.getParameter(string), you're going to get null
pointer error if no value was given. shouldn't the page display an error
message, since it doesn't have the email address to send a message. is
the friend's email a gauranteed value that is always present?

a bit more information would make it easier to diagnose.

peter


Wim Bervoets wrote:
> 
> Hello,
> 
> I have the following code:
> 
> <c:choose>
> <c:when test="(${param.yourName} != '') and (${param.yourEmail} != '') and
> (${param.friendsEmail1} != '')">
>         email something
> </c:when>
> <c:otherwise>
>         [<c:out value="${param.yourName}"/>]
>         [<c:out value="${param.yourEmail}"/>]
>         [<c:out value="${param.friendsEmail1}"/>]
>         [<%=request.getParameter("yourName")%>]
>         [<%=request.getParameter("yourEmail")%>]
>         [<%=request.getParameter("friendsEmail1")%>]
> </c:otherwise>
> </c:choose>
> 
> If the request paramaters are not empty I would like to send a mail - eg.
> execute the when.
> - otherwise execute the otherwise.
> 
> Problem I have is that c:otherwise is always executed - even when the
> parameters are set (I can see they are set because of the c:out's)
> 
> So how can I check for an empty string or null ? ${param.yourName} != null
> or ${param.yourName} != '' doesn't work !
> I'm using resin 2.0.5  - maybe it has something todo with the forEach
> problem that was fixed recently in resin 2.1.0 ?
> 
> Thanks
> Wim
> 
> --
> To unsubscribe, e-mail:   <mailto:taglibs-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:taglibs-user-help@jakarta.apache.org>

--
To unsubscribe, e-mail:   <mailto:taglibs-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:taglibs-user-help@jakarta.apache.org>


Mime
View raw message