views:

926

answers:

4

Tired of old EL in JSP not being able to invoke methods on beans etc.

Can I use SpEL from Spring 3.0 in my JSP:s?

+3  A: 

It would be nice, wouldn't it, but no, JSP EL is a function of the JSP compiler. The best you could do would be to write a custom taglib which evaluated contained SpEL expressions, which would be rather clunky.

skaffman
+1  A: 

If an upgrade is possible, you can get method invocation support in the latest JSP EL/JEE implementations (e.g. JEE6 using Glassfish v3). The JUEL (an EL implementation) doc page suggests you can upgrade either by putting the classes into your JRE's ext directory or by putting them in WEB-INF/lib and relying on the SPI mechanism (this depends on your container supporting this). The latest JUEL version supports method invocations.

I don't know enough about the Spring implementation to know how they plug in their EL support.

McDowell
Is it possible to use JUEL in Tomcat? And there won't be any conflicts with SpEL?
D. Wroblewski
+5  A: 

The upcoming Spring Framework 3.0.1 release adds a new spring:eval JSP tag that allows you to evaluate SpEL expressions from JSP pages. Future versions will add native integration with JSP 2.1 or > engines via a Unified EL adaption layer.

kdonald
Yes indeed: https://jira.springsource.org/browse/SPR-6827
skaffman
+1  A: 

I use JBoss EL within Tomcat in the manner described by McDowell. I included the jboss-el.jar in WEB-INF/lib for my application and added this snippet to web.xml:

  <!-- jboss el expressions allow method params -->
  <context-param>
    <param-name>com.sun.faces.expressionFactory</param-name>
    <param-value>org.jboss.el.ExpressionFactoryImpl</param-value>
  </context-param>
Peter Centgraf