I have a web application which runs on our company intranet. The application uses JSPs and JavaBeans (no EJBs) and runs on WebSphere App Server version 4.0.3. I would like to know if it is possible to get the machine name or IP of the pc that is used to access the application. I would like to store the machine name or IP in the database in our audit log. I don't know if this is allowed due to security issues. Can anyone please comment and let me know if this is possible? I appreciate any direction that you can give me. Thanks.
As Matthew points out, you can use request.getRemoteAddr and request.getRemoteHost. However, don't forget that this information is not always as specific as you might want. The same PPP user will probably have a different IP address each time they dial in, and different corparate users could have the same address if they use a proxy (same goes for multiple different users on a shared system like a big Unix box). - Marty
Thanks for responding. I have tested your suggestions: request.getRemoteAddr() and request.getRemoteHost() return the same value. What is the difference between the two? Should they be returning the same value? My web app runs on our intranet, as well as having remote access from the internet. Would either of these methods give me a unique identifier? Thanks again for your help.
Joined: Jan 18, 2001
Can someone please address my concerns listed above? I appreciate your help!
Both getRemoteAddr() and getRemoteHost() start with the same information, but getRemoteHost() will try to resolve the IP Address to a host name. If it can't resolve the address, or chooses not to try for performance reasons, then it also returns the IP address. I'm not sure what you mean by a unique identifier. Both methods return different views of the same thing, not fundamentally different information.