Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need Help getting Referrer IP in Servlet

 
Randall Stevens
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a situation where an Access Controller is redirecting the request to my server. The question I have is how do I retreive the IP address of the Access Controller?
brief code examples would be appreciated, as it has been a long time since I have worked with Servlets and JSPs.
Randall
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm assuming you're retrieving the IP address of the Controller, while you are in the responding servlet (the application the Controller redirects to).

For the originating server, you use request.getRemoteHost() and request.getRemoteAddr()

FWIW: I'm not actually sure of how to retrieve the IP address of the responding server, but you get the hostname of the responding server with request.getServerName()
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic