• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to get Client IP At Server Side in RMI  RSS feed

 
UmaShankar Adha
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends
I have developed a java web service. It is working fine. Now I need to get client IP address when user trying to call a method on server interfaces. At server end in xxxxxImpl.java file I have implement ServletLifeCycle Interface and implement init() and destroy() methods. When user try to call any method on server interface then this init() method will execute successfully. Now I am unable to find out how can I find out client IP. When client call a method on server interface (stub) then I need to get Client IP.
I need to implement IP based security in web service.
I have also tried
<< System.out.println("Client Host:-+java.rmi.server.RemoteServer.getClientHost()); >>

in Init method and stub file. But when it execute then it will throw an exception like
<< Exception:-java.rmi.server.ServerNotActiveException: not in a remote call>>


Can any one help me? Please reply me on adha.umashankar@dotsquares.com.

Thanks
USA
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think the init() method is called every time a client calls a method on the service... I think that it's called once the first time the server needs to set up the web service...

So init() is actually called by the server itself rather than from the client in any way - not a remote call... methods that *are* remote calls are those that you expose through your service interface. Have you tried getting the client IP there?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!