PDA

View Full Version : Need access to Spring ApplicationContext from EL function


bcompton
Oct 10th, 2005, 11:23 AM
I need to develop a JSP EL function for a web application I am working on. This function needs to be able to somehow find the Spring ApplicationContext to call getBean and call some business logic. It appears that the EL functions are implemented as methods in a POJO which does not have access to the PageContext from which I could find the Spring ApplicationContext. I am using org.springframework.web.context.ContextLoaderListe ner to initialize the ApplicationContext.

My question is: Is there some easy way to locate the ApplicationContext?

robh
Oct 13th, 2005, 08:15 AM
You can locate the WebApplicationContext using WebApplicationContextUtils and passing in the ServletContext.

Rob

bcompton
Oct 13th, 2005, 10:58 AM
Unfortunately, the class which implements the EL function does not have visibility to the ServletContext or PageContext. So, I need some way of looking up the application context using a singleton or JNDI or threadlocal or something like that.

Any ideas?