Forums Register Login

Boolean operations inside conditional tags

+Pie Number of slices to send: Send
When I run this code, I get True test failed. I would have thought that I would get True test passed since you can do boolean operations inside an EL statement.


[ July 06, 2006: Message edited by: Jacob Fenwick ]
+Pie Number of slices to send: Send
I see no EL statement in the code you posted.

(That's a strong hint).
+Pie Number of slices to send: Send
 

(That's a strong hint)


And it will cost Jacob a few dollars (that's another strong hint)
+Pie Number of slices to send: Send
Ok, so it doesn't actually contain an expression. I thought the part where the test attribute was evaluated was an expression, but I guess an expression is actually anything where ${x} is replaced by x.
What would you call the test attribute that gets evaluated?
The original statement where I was having the problem did have an expression in it. I've included it below.
At first I thought it might not have worked because EL didn't recognize null, but then I did the test with the two trues that are OR'd together and saw it fail, so now I want to know why you can't OR two statements inside a c:when tag or a c:if tag, or whatever other conditional tag you might use.



[ July 06, 2006: Message edited by: Jacob Fenwick ]
+Pie Number of slices to send: Send
 

Originally posted by Jacob Fenwick:
Ok, so it doesn't actually contain an expression. I thought the part where the test attribute was evaluated was an expression, but I guess an expression is actually anything where ${x} is replaced by x.



All EL expressions are enclosed in the ${} delimiters. In your example

<c:when test="true || true">



there is no EL expression. The value passed to the test attribute is the string "true || true".

If you want it to be an EL expression, you need to use the correct syntax:



then I did the test with the two trues



As I pointed out, you did not. Your test is flawed as described.

now I want to know why you can't OR two statements



You can.
+Pie Number of slices to send: Send
Thanks Bear. I was going to ask another question because I was still having problems but I figured it out. Oh well, I'll post what I learned anyways since I already typed it.

I thought something like this might work:

If I only put in param.returnuri==null and then didn't pass a variable, or if I only use param.returnuri=='null' and then pass the variable null, then it works. But as soon as I add in the OR, it stops working.

This was ludicrous but I tried it anyways:

Of course it's not proper syntax so it failed.

I finally did:

[ July 06, 2006: Message edited by: Jacob Fenwick ]
+Pie Number of slices to send: Send
Jacob, do you know the 'empty' operator ?
${empty param.returnuri}
+Pie Number of slices to send: Send
 

I finally did:



Yes, the ${} encloses the entire EL expression. It is not some sort of fetch operator. This is a common misconception, so don't feel too bad about it.

And, as Satou pointed out, the empty operator will return true if the operand is null or the empty string.
The only thing that kept the leeches off of me was this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1447 times.
Similar Threads
Mixing JSP and Scriptlets throws compilation errors
Nesting JSTL Tags
Struts display:column when/otherwise
Total newby JSP if block question is this legal
Getting Checkbox value - DisplayTag library
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 00:51:35.