1

All the answers I read discuss the container injecting the SessionContext on the EJB itself, but what if I wanted to get at the current SessionContext without having an EJB?

1 Answers1

0

If you know any EJB name for which you would like to get Context somewhere inside a servlet then you could do something like below. But trying to get context without EJB context will result in NameNotFoundException.

InitialContext ic = new InitialContext();
SessionContext sctxLookup = (SessionContext) ic.lookup("java:comp/env/com.TestBean/sctx");

Phani
  • 5,319
  • 6
  • 35
  • 43