Announcement Announcement Module
No announcement yet.
using a standalone servlet with the DispatcherServlet Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • using a standalone servlet with the DispatcherServlet

    hey all,

    i have a spring mvc application and i'd like to map a pre-existing servlet with my SimpleUrlHandlerMapping. the servlet in question is fairly trivial. it takes a Request, processes it and sends a redirect via the Response. i want to be able to manage the servlet under spring so i can inject a service dependency into it. ive attempted extending HttpServletBean and FrameworkServlet without much luck (and i suspect thats the wrong approach.) anyone know what the right way to go about this is (or if its even possible...) ?

  • #2
    Well, if the servlet is really simple, I would port it to an AbstractController, which is as simple as a servlet really.

    I don't know if you can inject dependencies directly into servlets, as their lifecycles are outside the scope of Spring. I could be wrong.

    You could, though, simply look up the dependency using WebApplicationContextUtils.

    So, for the mapping, you can use either ServletForwardingController or ServletWrappingController.