• Post Reply Bookmark Topic Watch Topic
  • New Topic

How can I do servlet dependency injection in servlet spec 2.4?  RSS feed

Dave Alvarado
Ranch Hand
Posts: 436
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!