File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes jstl simple equals on attribute Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » JSP
Reply 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: 35241
    
    7
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 ]

Android appsImageJ pluginsJava web charts
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56185
    
  13

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.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56185
    
  13

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://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: jstl simple equals on attribute
 
Similar Threads
jstl - fmt Tag problem
accessing size of an arraylist using tag
Spring Framework Petclinic example - tld error
Localize select box