Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between ContextLoaderListener and RequestContextListener?

Tags:

java

spring

I have googled it but not found satisfactory answer, it would be great if you guys can explain the difference between ContextLoaderListener and RequestContextListener.

like image 739
Juns Avatar asked Sep 10 '13 17:09

Juns


2 Answers

contextloaderlistener :- Bootstrap listener to start up Spring's root WebApplicationContext. Simply delegates to ContextLoader.

requestcontextlistener :- This listener is mainly for use with third-party servlets, e.g. the JSF FacesServlet. Within Spring's own web support, DispatcherServlet's processing is perfectly sufficient.

like image 102
Rahul Tripathi Avatar answered Oct 12 '22 09:10

Rahul Tripathi


If you use a Servlet 2.5 web container, with requests processed outside of Spring’s DispatcherServlet (for example, when using JSF or Struts), you need to register the org.springframework.web.context.request.RequestContextListener ServletRequestListener. For Servlet 3.0+, this can be done programmatically via the WebApplicationInitializer interface. Alternatively, or for older containers, add the following declaration to your web application’s web.xml file:

    <listener>         <listener-class>             org.springframework.web.context.request.RequestContextListener         </listener-class>     </listener>  </web-app> 
like image 36
SRK Avatar answered Oct 12 '22 09:10

SRK