Autowiring in servlet

I followed the solution in the following link, and it works fine:
Access Spring beans from a servlet in JBoss

public class MyServlet extends HttpServlet {

  @Autowired
  private MyService myService;

  public void init(ServletConfig config) {
    super.init(config);
    SpringBeanAutowiringSupport.processInjectionBasedOnServletContext(this,
      config.getServletContext());
  }
}

Leave a Comment