Thursday, June 2, 2016

init-param vs context-param

see for background. Gist:
context-param variables are global and accessible through the ServletContext. init-param variables are configured per servlet.

E.g. the org.springframework.web.servlet.DispatcherServlet can be explicitely set to use a particular application context file via init-param, i.e. setting the contextConfigLocation variable (which overrides the default <servlet-name>-context.xml)

Conversely, to register a Spring Security application context, Spring can make use of a contextConfigLocation global context-param variable which it reads via a listener: org.springframework.web.context.ContextLoaderListener -- which is also a handy way to bootstrap a Spring application on Tomcat startup. Note that the Spring Security bootstrap mechanism also relies on adding a filter: org.springframework.web.filter.DelegatingFilterProxy.

No comments:

Post a Comment