Meaningless Drivel is fun!*
The moose likes JSP and the fly likes jstl simple equals on attribute Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "jstl simple equals on attribute" Watch "jstl simple equals on attribute" New topic
Author

jstl simple equals on attribute

Alessandro Ilardo
Ranch Hand

Joined: Dec 23, 2005
Posts: 218
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
Marshal

Joined: Mar 22, 2005
Posts: 39552
    
  27
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 ]

Ping & DNS - updated with new look and Ping home screen widget
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60063
    
  65

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60063
    
  65

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?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jstl simple equals on attribute
 
Similar Threads
Localize select box
Spring Framework Petclinic example - tld error
jstl - fmt Tag problem
accessing size of an arraylist using tag