• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to trace Client IP address

 
Greenhorn
Posts: 28
Mac Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How can i trace the users IP address from a web application.. i tried with some existing methods in java. but its showing servers ip address..

How can i solve it..?
 
Saloon Keeper
Posts: 7585
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The HttpServletRequest object has methods to get the remote IP address. If you get "127.0.0.1" or some other local IP address, ask your server admin whether there's some kind of forwarding going on (also google for "x-forwarded-for" in that case).
 
Sam Jimzz
Greenhorn
Posts: 28
Mac Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Moores wrote:The HttpServletRequest object has methods to get the remote IP address. If you get "127.0.0.1" or some other local IP address, ask your server admin whether there's some kind of forwarding going on (also google for "x-forwarded-for" in that case).



yes..i tried with 2-3 methods in HttpServletRequest. but still in vain. we have two servers for balancing the load,while executing the code,its just retrieving the proxy address.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Then you must set up your load balancers to forward the actual client's IP address.
 
Sam Jimzz
Greenhorn
Posts: 28
Mac Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Spoor wrote:Then you must set up your load balancers to forward the actual client's IP address.



Is there any other way(3rd party packages,api) to catch the IP address without disturbing load balancers config.?
 
Tim Moores
Saloon Keeper
Posts: 7585
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The use of x-forwarded-for is the standard way to do this. Have you checked that it's not being used (and thus available to your servlet) already?
 
Sam Jimzz
Greenhorn
Posts: 28
Mac Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Moores wrote:The use of x-forwarded-for is the standard way to do this. Have you checked that it's not being used (and thus available to your servlet) already?


Yes i tried with the following code.,

But still getting the same address(server IP)..
 
Tim Moores
Saloon Keeper
Posts: 7585
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to have a chat with your server admin, then.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic