• Post Reply Bookmark Topic Watch Topic
  • New Topic

Comparing variables using JSTL

 
M Burke
Ranch Hand
Posts: 406
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have this construct in my jsp. I traced the values for each string and they are identical. So why does JSTL think the strings are not equal? I also tried 'eq'.

<c:choose>
<c:when test="requestScope.formEvent ==applicationScope.DServiceGlobalForms.FORM_EVENT_PROFILE" >
<jsp:include page="${applicationScope.DServiceGlobalForms.FORM_TYPE_MAIN_USER_PROFILE}"/>
</c:when>
<ctherwise>
 
</ctherwise>
</c:choose>
 
Hunny Lee
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by M Burke:
...



Try adding ${} to your test (on c:when). That should work, assuming that formEvent and DServiceGlobalForms are set correctly.
 
M Burke
Ranch Hand
Posts: 406
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I tried this...
<c:when test="${requestScope[DServiceGlobalForms.FORM_EVENT]} == ${applicationScope.DServiceGlobalForms.FORM_EVENT_PROFILE}" >

and this...

<c:when test="${requestScope[DServiceGlobalForms.FORM_EVENT] == applicationScope.DServiceGlobalForms.FORM_EVENT_PROFILE}" >


But I get a 500 error "According to TLD or attribute directive in tag file, attribute test does not accept any expressions
"
 
M Burke
Ranch Hand
Posts: 406
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It works now, but I am not sure why. I assume it has to do with which JSTL version I am using. I am using 1.1

I changed...
<%@taglib prefix="c" uri="http://java.sun.com/jstl/core" %>

to...
<%@taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
[ February 23, 2007: Message edited by: M Burke ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65519
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by M Burke:
It works now, but I am not sure why. I assume it has to do with which JSTL version I am using. I am using 1.1


No. You're not. Both of those URI's are JSTL 1.0 URIs.

The JSTL 1.1 URI is http://java.sun.com/jsp/jstl/core
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!