In my Java EE 6-webapp (running on latest GlassFish 3.1), I'm using JSF2-ManagedBeans and @ManagedProperty
to inject them into other ManagedBeans. Now i would like to know if i can also inject a @ManagedBean
into a @WebServlet
, using @ManagedProperty
. Some code:
@WebServlet(name = "vdd")
public class VddServlet extends HttpServlet
{
@ManagedProperty(value = "#{userIdentity}")
private UserIdentity identity;
}
The ManagedBean looks like this:
@ManagedBean
public class UserIdentity
{
...
}
Does it work like this? If not, what other ways do i have to inject a ManagedBean into a WebServlet (without CDI, which is currently not an option - since there are some issues in GF 3.1 B32/33 in combination with OSGi-Java EE-apps, but we are short on time)?