Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can we get Remote IP Address without using HttpServletRequest?

 
Koti Samadhi
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How? The request is the *only* information you have from the client, no?
 
Sherif Shehab
Ranch Hand
Posts: 485
Android Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David is totally right , but the question here is why you wanna get Remote IP Address without using HttpServletRequest? !!
 
jay vas
Ranch Hand
Posts: 407
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic