Eternal_Student
asked on
JSTL OR statement
Im familiar with JSP but im struggling to pull off this OR statement in JSTL:
<c:choose>
<c:when test="${whatever}" || test="${whatever}">
Not linked
</c:when>
<c:otherwise>
<a href="whatever.jsp>">Linke d</a>
</c:otherwise>
</c:choose>
If you can see I am trying to do an OR statement in the <c:when> tag but it is not liking the syntax I think?
<c:choose>
<c:when test="${whatever}" || test="${whatever}">
Not linked
</c:when>
<c:otherwise>
<a href="whatever.jsp>">Linke
</c:otherwise>
</c:choose>
If you can see I am trying to do an OR statement in the <c:when> tag but it is not liking the syntax I think?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
what is value of whatever?
ASKER
The value doesnt really matter at this stage I just am worried about getting the syntax correct!
You can only have one test attribute in the when tag. Did you have a error message ?
ASKER
Yes but I cannot recall what it was now. It was something about an illegal <c:when> error.
There needs to be two different tests in the when otherwise how can I do this? One tests the url to see what page it is, the other test to see if there are any records for that page. So two completely different tests but I want the outcome for both to be the same that is why I was trying to use the OR statement.
Would it be easier for me to do:
<c:choose>
<c:when test="${whatever}">
Not linked
</c:when>
<c:otherwise test="${whatever2}">
Not Linked
</c:otherwise>
<c:otherwise>
<a href="whatever.jsp>">Linke d</a>
</c:otherwise>
</c:choose>
Is that correct? ^
There needs to be two different tests in the when otherwise how can I do this? One tests the url to see what page it is, the other test to see if there are any records for that page. So two completely different tests but I want the outcome for both to be the same that is why I was trying to use the OR statement.
Would it be easier for me to do:
<c:choose>
<c:when test="${whatever}">
Not linked
</c:when>
<c:otherwise test="${whatever2}">
Not Linked
</c:otherwise>
<c:otherwise>
<a href="whatever.jsp>">Linke
</c:otherwise>
</c:choose>
Is that correct? ^
No, that 's I am asking ,what is value of whatever...with whome you want to compare it..
<c:choose>
<c:when test="${1==1}">
Linked...
</c:when>
<c:otherwise>
<a href="whatever.jsp>">Linke d</a>
</c:otherwise>
</c:choose>
<c:choose>
<c:when test="${1==1}">
Linked...
</c:when>
<c:otherwise>
<a href="whatever.jsp>">Linke
</c:otherwise>
</c:choose>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
<c:choose>
<c:when test="${whatever || whatever2}">
Not linked
</c:when>
<c:otherwise>
<a href="whatever.jsp>">Linke d</a>
</c:otherwise>
</c:choose>
<c:when test="${whatever || whatever2}">
Not linked
</c:when>
<c:otherwise>
<a href="whatever.jsp>">Linke
</c:otherwise>
</c:choose>