File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 45


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: 60050
    
  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: 45

Bear Bibeault wrote:Pass it to the class as an argument of one of its methods.
Thanks It's working
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: get client Ip in simple java class
 
Similar Threads
Extracting Client's IP
How to get Mac Id of my client machine
Server/Client On Separate Machines
session object behaves like application (scope)
The best way to transfer files