Solved

JSTL OR statement

Posted on 2007-03-30
8
4,285 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
withoutTen challenge 14 88
changePi Challenge 15 77
Exception after setting jdbc session management 2 38
wordlen challenge 3 49
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.

744 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

9 Experts available now in Live!

Get 1:1 Help Now