How can i retrieve from inside my Bean(Stateless session and Entity CMP) the user name which i am serving (the user name of user just logged in my web application)

Inside an EJB you may retrieve the "Caller" name, that is the login id by invoking: sessionContext.getCallerIdentity().getName() where sessionContext is the instance of "SessionContext" (setSessionContext) passed to the Session Bean, or the instance of "EntityContext" (setEntityContext) passed to the Entity Bean.

Showing Answers 1 - 4 of 4 Answers

uma

  • Feb 12th, 2006
 

u can get the information abt the client(who invoked the bean) by the EJBContext methods.There r 2 types

1)SessionContext and 2)EntityContext.

These r used get the information abt the container,the client and get reference of the bean itself.

  Was this answer useful?  Yes

Sony V George

  • Apr 4th, 2007
 

You can get the User Name  by using the following code

sessionContext.getCallerIdentity().getName()

There is having two types of context 1.SessionContext
2.EntityContext

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions