java - dependency injection in a servlet 3.0 web app? -


i'm trying write servlet 3.0 web app, learn basic servlet handling. use spring.

now have servlet access dao queries database. now, best way instantiate dao , use it? best guess have private property in servlet , create instance of dao when servlet created.

but, servlet created multiple times?

is there similar springs dependency injection available in servlet 3.0?

ejb 3 dependency injection extremely simple use. single annotation, @ejb, causes injection of declared bean. injection of somedao bean servlet 3.0 looks this:

@webservlet(name="messenger", urlpatterns={"/messenger"}) public class messenger extends httpservlet {         @ejb     somedao somedao;  } 

the injected somedao bean interface or no-interface view bean. long there 1 implementation of interface, injected without ceremony.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -