Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

EL && Logic Operators  RSS feed

 
Higgledy Smith
Ranch Hand
Posts: 193
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I cannot find an understandable example of this anywhere, if this is obvious to everyone, I apologize.

I need to AND three variables. In Java, I would do this:



In EL, I tried these but with not luck:



and



Any help is appreciated. Thank you.
Higgledy
 
Michael Ku
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that you need to put () around the three like you do in the original example
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The whole test needs to be one xml attribute value.
Try:
 
Higgledy Smith
Ranch Hand
Posts: 193
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you. I cannot believe it was so obvious. With Java, you can lookup the availble methods for a class in the Java API. But with El and JSTL, there APIs don't seem to coorelate to methods or even make much sense.

Example:

c: relates to the jstl/core (JSTL TAG)
I look up the core API here> JSTL 1.1 API
But I cannot find any if or test, just a link to ConditionalTagSupport

So, how am I to know what is availble with the jstl librarby?

Thank you.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
EL is covered in the JSP spec.

This FAQ entry has urls for downloading the JSP and JSTL specifications.

They're a good thing to have on your desktop when developing JSP pages.
 
Higgledy Smith
Ranch Hand
Posts: 193
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess I am dense. I listed the jstl.core, sub-sections below. How am to know from this that an if function is availble?

 
Higgledy Smith
Ranch Hand
Posts: 193
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What I really am looking for is an if-else tag. You showed me how to do the <c:if...> but I did not want to post again asking how to do an if else. Trouble is I can't even find a reference to the if in the spec let alone the if else.
 
Tim Holloway
Bartender
Posts: 18705
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JavaDocs are generally the WORST place to get details on how to program with a java resource. They show the trees, but unless someone got ambitious, they don't show how the trees fit in the forest.

Try this URL: http://java.sun.com/j2ee/1.3/docs/tutorial/doc/JSTL5.html

Note that there IS no "else" logic tag. You have to either repeat the "if" with reversed logic or use the "otherwise" element on a single-test choose construct. This because of the way HTML/JSP/XML tags have to nest - there's no tidy way to do if/optional-else/endif coding.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One note to Tim's excellent post.
The ctherwise tag works with the c:when tag, not the c:if tag.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!