How to Find IPAddress of Client
How do I write a JAVA servlet that will let me find the ip address of the client?
|
Just look up the inet address in the Socket object after you accept the connection:
http://java.sun.com/j2se/1.5.0/docs/...et/Socket.html |
You can also use the httpservletrequest methods. I think there is a remoteaddress method or something like it that you can use.
|
HttpServlet method getRemoteuser is present that gives login not ip.
Also I dont use a socket... I use HttpServletRequest and Response. Is that inherited from Socket? If there is a simple way in asp.net then that will also do.. |
mrcheeks is absolutely correct. Look here:
http://www.oracle.com/technology/sam...lientInfo.html |
Really sorry! Really stupid dumb thing I did. I looked at the HttpServletRequest API and forgot to check the inherited methods.
Thanks a lot ya all. |
But the getRemoteAddr funtion returns ip of the last used proxy whereas I want the ipaddress of the actual user.
How do I do that? |
I dont think you will be able to get the real IP address of the client using the Java Http Servlet API. The request.getRemoteAddr() will give you the IP address of proxy server the client is behind.
|
Quote:
|
Check out whatsmyip. For me its able to show the ip assigned over the intranet too. i.e my router's ip(203.*.*.*) and my internal lan ip (172.16.*.*) . How is it able to do that? And it doesn't even seem to be loading a slow ass Java applet too.
|
All times are GMT -5. The time now is 11:07 AM. |