Is it ok to define both the ContextLoadListener and DispatcherServlet in the web.xml or are they mutually exclusive?
Is it ok to define both the ContextLoadListener and DispatcherServlet in the web.xml or
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, they’re not mutually exclusive.
ContextLoaderListenermanages an appcontext which is associated with the whole webapp.DispatcherServletmanages a context associated with that specific servlet. The webapp context is the “parent” of the servlet appcontext, and all beans in the webapp appcontext are visible to beans in the servlet appcontext.If you have only one servlet, there’s not many reasons to use
ContextLoaderListener. If you have multiple servlets, it’s good to put the shared beans in the webbapp context where practical, so they can be reused.