How can I do servlet dependency injection in servlet spec 2.4?
posted 4 years ago
I'm using Tomcat 6.0.33 (Servlet Api 2.4) and Java 6 but no other frameworks. Is it possible, and how, can I inject dependencies into my servlet? I have tried the @Resource annotation, but I believe this is only supported for servlet spec 2.5 and above. In my HttpServlet, I have
and in my web.xml I define
but again, this isn't working (the field in the servlet is still null) and I suspect that's because of the wrong servlet API version. Any other ways you know to inject my bean are greatly appreciated, - Dave