Solved

JSTL OR statement

Posted on 2007-03-30
8
4,332 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

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
micro services vs rest web services 16 126
custom annotations 9 42
mysql jsp example issue 32 51
ejb message driven bean mdb creation steps 2 24
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…
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.

828 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