This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
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


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
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: 41575
    
  54
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 - my free Android networking tools app
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61066
    
  66

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: 61066
    
  66

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