views:

18

answers:

1

Let's say I have the following JSTL loop:

<c:forEach items="${foos}" var="foo" varStatus="status">
    <c:out value="${processedFoo}"/>
</c:forEach>

And let's say I have an external library com.foo.processor which contains a ProcessorFactory class with a process method.

How do I import this library and call the following code from inside the JSTL loop?

Foo processedFoo = com.foo.processor.ProcessorFactory.process(foo)
+3  A: 

You don't. Putting a lot of logic in the JSP layer leads to an application that is difficult to maintain.

You could create your own tag library that includes a custom function, but this sort of processing is best done by a servlet before forwarding the request to a JSP for rendering.

erickson