Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

get client Ip in simple java class

 
Divya Chandel
Ranch Hand
Posts: 47
MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi
In my project I store client Ip in database,I get that client IP in myservlet class.

like this-
String client_Ip = request.getHeader("X-FORWARDED-FOR");

if (client_Ip == null) {
client_Ip = request.getRemoteAddr();
}


In this way it's working,Now I want to use client_Ip value in my simple java class that is non-servlet class how I do this.
 
Vinodh Sa
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

Which technology or framework you are usng ???
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pass it to the class as an argument of one of its methods.
 
Divya Chandel
Ranch Hand
Posts: 47
MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Pass it to the class as an argument of one of its methods.
Thanks It's working
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic