This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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: 60766
    
  65

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
 
Don't get me started about those stupid light bulbs.
 
subject: get client Ip in simple java class
 
Similar Threads
Extracting Client's IP
How to get Mac Id of my client machine
The best way to transfer files
session object behaves like application (scope)
Server/Client On Separate Machines