aspose file tools*
The moose likes Servlets and the fly likes Can we get Remote IP Address without using HttpServletRequest? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Can we get Remote IP Address without using HttpServletRequest?" Watch "Can we get Remote IP Address without using HttpServletRequest?" New topic
Author

Can we get Remote IP Address without using HttpServletRequest?

Koti Samadhi
Greenhorn

Joined: Aug 26, 2009
Posts: 29
Hi All,

Can we get Remote IP Address without using HttpServletRequest?

I have the solution like below:

public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
InetAddress remoteInetAddress = InetAddress.getByName(req.getRemoteAddr());

}

Could you please provide me any alternate solution with out using HttpServletRequest ?

Thanks & Regards
Koti
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

How? The request is the *only* information you have from the client, no?
Sherif Shehab
Ranch Hand

Joined: Mar 05, 2007
Posts: 483

David is totally right , but the question here is why you wanna get Remote IP Address without using HttpServletRequest? !!


Thanks,
Sherif
jay vas
Ranch Hand

Joined: Aug 30, 2005
Posts: 407
The following code results in the output shown in comments.....



Thus none of these methods have useable information.

How can I get a real IP address Gets no useable data.... Why ? I need the users ip address for logging purposes... And I recall the "getRemoteAddr())" method as working.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12825
    
    5
In Tomcat server.xml there is an "enableLookups" setting - set this to true and see what happens.

The comments in server.xml explain it all.

Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can we get Remote IP Address without using HttpServletRequest?