I have a requirement to find the User Name and the IP Address of the client for each EJB method call. Using EJB Context object we can get the User name but how to get the IP Address of EJB Client. We are using IBM Websphere 5.2 Application Server.
Can you please let me know the solution. Thanks in advance.
Assuming that all the calls to your EJBs is from a controller servlet (which is the most common case unless u have a thick client making IIOP calls) u can track the IP address of the clients using ServletRequest.getRemoteAddr().Hope this answers your question.
Assuming that, servlet is the only client for the EJB,
you can do that using servlets request object and getting the client specific requirements.
If a Java or EJBs/MDBs are the client for the EJB method calls, you will not be able to get the IP address.
Having said, for each type of client(Java/EJB/MDB/ other components) that calls the EJB, you have to get information from the end clients and adopt a strategy to send end client information to EJB methods.
Above is the workaround to solve the generic problem.
Try to use the following method: