Announcement Announcement Module
Collapse
No announcement yet.
My HttpRequestHandler is not ServletConfigAware (why?) Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • My HttpRequestHandler is not ServletConfigAware (why?)

    Hello,

    I need a ServletConfigAware servlet that I have already configured as a HttpRequestHandler @Controller invoked by HttpRequestHandlerServlet.

    Unfortunately, my ServletConfigAware.setServletConfig() method is never called.

    I have modified the HttpRequestHandlerServlet to call ServletConfigAware.setServletConfig() if the target servlet is a ServletConfigAware, but there must be a cleaner way to do it.

    Do you know what I should do?

    If it helps, I added the ContextLoaderListener and RequestContextListener listeners to my web.xml, and also the contextConfigLocation pointing to classpath:applicationContext.xml where I use the <context:component-scan> tag to make Spring look for my annotated beans (this works, the only problem is the ServletConfigAware interface; Spring is not "aware" of it!). I don't use Spring MVC (just servlets and also Jersey integrated with Spring).

    Thanks in advance!

    Ferran

  • #2
    And why should it? There is no servletconfig in the ContextLoaderListener... The thing is called ServletConfig for a reason it belongs to a servlet and hence is only available for the DispatcherServlet. The ContextLoaderListener doesn't know anything about a ServletConfig...

    Comment


    • #3
      But the HttpRequestHandlerServlet knows about the ServletConfig, although it never passes it to the HttpRequestHandler target it manages. I supposed there would be a way to do it.

      Do you think I need the DispatcherServlet? I saw that class is from the Spring MVC and I don't use Spring MVC. Is it OK to use it anyway? In that case, how should I configure my beans (my servlets and other non-servlet beans)? Now I just have an applicationContext.xml. Should I move all my beans to a servletContext.xml or only the servlet beans? In case I separate the contexts, how would my servlet beans see my non-servlet beans?

      I know I should ask some of those questions in other threads, but I already tried to find the answers with no luck.

      Thank you very much!
      Ferran
      Last edited by ferranmc; Nov 24th, 2011, 04:39 AM.

      Comment


      • #4

        But the HttpRequestHandlerServlet knows about the ServletConfig, although it never passes it to the HttpRequestHandler target it manages. I supposed there would be a way to do it.
        That doesn't matter... The problem is you are loading the config with the ContextLoaderlIstener if doesn't matter how many servlets you have. The fact remains the ContextLoaderListener is loading the configuration and that knows nothing about a ServletConfig.

        Comment

        Working...
        X