Jan 14th, 2007, 07:57 AM
How to access DispatcherServlet's context from another Servlet?
Basically what I'm trying to do is to add Spring-based services into an existing servlet application. I'm not really happy about the idea of destroying the current architecture, so it would be better for me to leave it, and to add Spring DispatcherServlet which would initialize all the beans for me.
The problem I'm facing with is that I can't see a way to access DispatcherServlet's context from another Servlet. It seems that RequestContextUtils and WebApplicationContextUtils classes are of little help here, so maybe someone will point me to some other way of working this out?
Of course, I understand that I can initialize Spring by hand in my legacy servlet and don't use DispatcherServlet at all, but it's really interesting for me to know is there a solution that gets pre-initialized context from spring servlet.
Thanks in advance!
Jan 14th, 2007, 02:07 PM
Why not use ContextLoaderListener to load the context, which will then be accessible through WebApplicationContextUtils from anywhere in the same web app?
Jan 15th, 2007, 01:58 AM
Thanks alot! Quite easy, but it helped!