Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jstl simple equals on attribute

 
Alessandro Ilardo
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello there,
I'm quite new with jstl and I've alredy made a search.

A jsp page expects to receive a parameter or an attribute (called "id"), it uses that to retrieve an object from an ArrayList which should find a match with a same attribute name.

At the moment I understood how do that passing the parameter
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@taglib uri="http://jakarta.apache.org/taglibs/request-1.0" prefix="req" %>
<c:forEach var="item" items="${sessionScope.newsList}">
<c:if test="${item.id == param.id}">

But I'm stuck tring to modify that condition in something like
<c:if test="${item.id == param.id || item.id == requestScope.id}">
which doesn't work for some reasons that I don't know.

I'd apreciate any help from you.
Thanks in advance.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The EL in JSTL uses the "eq" operator to test for equality, not "==", and it uses "or", not "||". I'm not enough of an expert on EL to say whether those have identical meaning, but that's where I'd start to investigate.
[ February 04, 2007: Message edited by: Ulf Dittmer ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64835
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ulf Dittmer:
The EL in JSTL uses the "eq" operator to test for equality, not "==", and it uses "or", not "||".


Ulf is mistaken (sorry Ulf), the EL allows the use of either of the symbolic or alphabetic operator notations.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64835
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Alessandro Ilardo:
which doesn't work for some reasons that I don't know.


"it doesn't work" is the single most useless phrase that appears quite often here.

How does it not work? How did you verify that it's not working? How did you prove that the conditions set up prior to the expression contain what you think they contain?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic