This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
I need to instantiate a Spring applicationcontext in a Servlet. Is there any best way to do this ?
Also,
If the same ApplicationConext needs to be shared among many servlet, what would be the best way ?
Thanks and Regards,
Abhijit Salunkhe
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.