views:

30

answers:

1

Hi at All

I have a little question...

On my JSP page I have a List of beans. I want to extract a sublist of beans with a specific property (Ex. all Horror books). Can Apache Beanutils help me?

Thanks in advance...

+1  A: 

In a JSP you have 2 options:

  1. Iterate over list yourself using JSTL <c:forEach> and test using JSTL <c:if> if the item matches the requirements and finally just display it.

  2. Do the same in plain Java code and call this in a servlet prior to forwarding the request to the JSP. Optionally you can wrap this in an EL function so that you can call it from inside a JSP.

The Commons Beanutils can't help much here. It has as far as I know no collection filter with a predicate. The Commons Collections and Google Collections however have.

BalusC