• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Comparing variables using JSTL

 
Ranch Hand
Posts: 428
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>
<c:otherwise>
 
</c:otherwise>
</c:choose>
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 428
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 428
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Sheriff
Posts: 67637
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
What do you have in that there bucket? It wouldn't be a tiny ad by any chance ...
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic