I need to instantiate a Spring applicationcontext in a Servlet. Is there any best way to do this ?
If the same ApplicationConext needs to be shared among many servlet, what would be the best way ?
Thanks and Regards,
Best way is to use the ContextLoaderListener in your web.xml This will create an ApplicationContext for you when you deploy you war. This app context will be placed in your ServletContext for that app.
Now that code is not 100% compilable, you have to fill in the servletContext variable and my method call might be slightly wrong, but your IDE will tell you what methods are on the ServletContextUtils class.