1

I want to load servlet before loading Listener but I am not getting any idea how to implement it.Any leads??

kryger
  • 12,906
  • 8
  • 44
  • 65
sandeepp
  • 31
  • 3
  • 1
    You certainly do not need that, and anyway Java EE does not allow it. – Serge Ballesta Jun 24 '16 at 12:51
  • I smell a strong http://xyproblem.info here. What problem exactly are you trying to solve for which you incorrectly thought that it would be the correct solution to load the servlet before the context is initialized? Perhaps the servlet's task you had in mind actually belongs in a servlet context listener like this? http://stackoverflow.com/q/3468150 – BalusC Jun 24 '16 at 13:11

1 Answers1

3

You can't.

ContextLoaderListener is a ServletContextListener and as such, it is notified with two event methods: contextInitialized and contextDestroyed

As specified by the Servlet specification contextInitialized contract:

Receives notification that the web application initialization process is starting.

All ServletContextListeners are notified of context initialization before any filters or servlets in the web application are initialized.

Ori Dar
  • 18,687
  • 5
  • 58
  • 72