Solved

JSTL OR statement

Posted on 2007-03-30
8
4,301 Views
Last Modified: 2013-11-24
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>">Linked</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?
0
Comment
Question by:Eternal_Student
  • 3
  • 3
  • 2
8 Comments
 
LVL 27

Accepted Solution

by:
rrz earned 100 total points
ID: 18824713
><c:when test="${whatever}" || test="${whatever}">
try instead
<c:when test="${whatever || somethingElse}">
0
 
LVL 11

Expert Comment

by:Manish
ID: 18824879
what is value of whatever?
0
 
LVL 18

Author Comment

by:Eternal_Student
ID: 18826534
The value doesnt really matter at this stage I just am worried about getting the syntax correct!
0
 
LVL 27

Expert Comment

by:rrz
ID: 18826871
You can only have one test attribute in the when tag. Did you have a error message ?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 18

Author Comment

by:Eternal_Student
ID: 18828211
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>">Linked</a>
      </c:otherwise>
</c:choose>

Is that correct? ^
0
 
LVL 11

Expert Comment

by:Manish
ID: 18828269
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>">Linked</a>
      </c:otherwise>
</c:choose>
0
 
LVL 11

Assisted Solution

by:Manish
Manish earned 25 total points
ID: 18828278
0
 
LVL 27

Expert Comment

by:rrz
ID: 18828635
<c:choose>
      <c:when test="${whatever || whatever2}">
              Not linked
      </c:when>
      <c:otherwise>
              <a href="whatever.jsp>">Linked</a>
      </c:otherwise>
</c:choose>
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
copyEndy  challenge 15 83
mergeTwo  challenge 13 82
JAVA part two 5 55
what is the main difference between git clone and fetch ann pull and push commands 2 67
I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

939 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

3 Experts available now in Live!

Get 1:1 Help Now