Solved

JSTL OR statement

Posted on 2007-03-30
8
4,375 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
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

Linux Academy Android App Now Supports Chromecast

We have some fantastic news for our Android fans. We’re so excited to announce that the Linux Academy Android app is now available with Chromecast support. That’s right – simply download the latest update of the Linux Academy App and start casting your favorite course videos!

Question has a verified solution.

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

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
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.

636 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