Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

<c:when> problem

Posted on 2006-11-10
9
Medium Priority
?
227 Views
Last Modified: 2011-10-03
I have a variable in a JSTL Page I need to send to a choose block.  Problem is, I can't get any 'when' block to match.  In all cases, the <c:otherwise> is printed.
form.type is a String.

What am I dong wrong?

For this example, form.type is set to the String "foo".  So, "Showing FOO" should print.

------begin------------
type= <c:out value="${form.type}"/> <br>

<c:choose>
  <c:when test="${form.type  == 'foo'}">
    Showing FOO
  </c:when>
   <c:when test="${form.type == 'bar'}">
    Showing BAR
  </c:when>
  <c:otherwise>
      Unknown Content
  </c:otherwise>
</c:choose>
-------end-------------
0
Comment
Question by:tmonteit
  • 2
  • 2
  • 2
  • +3
9 Comments
 
LVL 28

Expert Comment

by:rrz
ID: 17919759
>type= <c:out value="${form.type}"/>
Does that print  "foo"  ?
0
 

Author Comment

by:tmonteit
ID: 17919775
Yes , <c:out value="${form.type}"/> prints "foo"
0
 
LVL 28

Expert Comment

by:rrz
ID: 17919812
I don't see an error.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 16

Expert Comment

by:Peter Kwan
ID: 17919818
what is instance type of your "type" variable defined in your "form" object? What I mean is, is the following true?

class MyForm { // For example
   String type;
}
0
 

Author Comment

by:tmonteit
ID: 17919830
Exactly ...

class MyForm {
   String type;
}
0
 
LVL 9

Expert Comment

by:owenli27
ID: 17919861
make sure no white-space char appended on form.type -- just for in case...
0
 
LVL 16

Expert Comment

by:suprapto45
ID: 17920279
Try to remove the second <c:when> but keep the <c:otherwise>. Just curious though

  <c:when test="${form.type  == 'foo'}">
    Showing FOO
  </c:when>
   <%-- Remove this --%>
   <%--
   <c:when test="${form.type == 'bar'}">
    Showing BAR
  </c:when>
   --%>
0
 
LVL 16

Expert Comment

by:Peter Kwan
ID: 17921460
What is your output for the following code:

a)
<c:if test="${form.type == 'foo'}">
   Showing FOO
</c:if>

b)
<c:choose>
   <c:when test="${'a' == 'a'}">
        Showing a
    </c:when>
   <c:otherwise>
        Not match
   </c:otherwise>
</c:choose>
0
 
LVL 4

Accepted Solution

by:
Hassan_Ghanem earned 1600 total points
ID: 17924249
try to write the condition this way ${form.type eq 'foo'} instead of ${form.type == 'foo'}
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Transferring FSMO roles is done when an admin wants to split roles between certain Domain Controllers or the Domain Controller holding the Roles has been forcefully demoted using dcpromo / forceremoval
How to fix a SonicWall Gateway Anti-Virus firewall blocking automatic updates to apps like Windows, Adobe, Symantec, etc.
Integration Management Part 2
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

971 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