Solved

JSTL OR statement

Posted on 2007-03-30
8
4,316 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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
 
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
dividesSelf challange 15 136
My project did see openJDK that I installed. What could be the problem 7 142
iterator/ListIterator approach 17 27
ejb on wildfly 5 20
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 …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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.

773 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