I referred to a lot of posts but still I am unable to find a correct working answer.
I want to get it from my Java class itself and not using EL in jsp.
How to get the servlet context path in Spring?
It's used to wire the configurations from Spring beans together and use them for the application. Use ApplicationContext if you want to retrieve the information of Spring beans. Use ServletContext if you want to get/set attribute those shared to all Servlet.
ServletConfig is used for sharing init parameters specific to a servlet while ServletContext is for sharing init parameters within any Servlet within a web application.
for SpringMVC
@Autowired ServletContext servletContext;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With