Issue
I'm trying to get rid of really old servlets and add in their place casual services.
Is this possible to get the same data from the application context as I was previously taking from the servlet context?
More specifically, I'm trying to get attribute servletContext.getAttribute("org.directwebremoting.ContainerList")
from application context, but ApplicationContext
doesn't have getAttribute
method.
Solution
Spring uses Servlet
s as backing technology. So you just need to obtain the ServletContext
related to that Servlet
and retrieve the attributes.
For the root context, use WebApplicationContext
. This interface adds a getServletContext()
method to the generic ApplicationContext interface.
Object attribute = webApplicationContext
.getServletContext()
.getAttribute("org.directwebremoting.ContainerList");
Answered By - Minar Mahmud