aspose file tools*
The moose likes Servlets and the fly likes get client Ip in simple java class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "get client Ip in simple java class" Watch "get client Ip in simple java class" New topic
Author

get client Ip in simple java class

Divya Chandel
Ranch Hand

Joined: Jun 09, 2011
Posts: 46


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.


Divya
SCJP1.6
Vinodh Sa
Ranch Hand

Joined: May 06, 2010
Posts: 55
Hi ,

Which technology or framework you are usng ???


Thanks, Vinodh
[Servlet tutorial]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61230
    
  66

Pass it to the class as an argument of one of its methods.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Divya Chandel
Ranch Hand

Joined: Jun 09, 2011
Posts: 46

Bear Bibeault wrote:Pass it to the class as an argument of one of its methods.
Thanks It's working
 
jQuery in Action, 2nd edition
 
subject: get client Ip in simple java class