Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1023
  • Last Modified:

How to retrieve a client's IP adress?

Hi!

I want to know if there is a way to retrieve a visitors IP adress using JavaScript.
I could also use JSP if that works better.

Please advise.

Regards,
David
0
larsan
Asked:
larsan
  • 3
  • 3
1 Solution
 
mrh30Commented:
In JSP it's quite easy:

<%
out.print( request.getRemoteAddr() );
out.print( request.getRemoteHost() );
%>
0
 
larsanAuthor Commented:
That works on a "standalone" page, but this page in particular is
included into another jsp, and the only IP I'm getting is that of the current server.

Sorry for not mentioning this earlier.

Regards,
David
0
 
mrh30Commented:
That's a bit more tricky, since the request is indeed coming from within your server when you do the include.  It's a sort of chain going on.

There might be a way for the 'parent' jsp to find it and then pass the IP as a parameter to the child in some way?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
larsanAuthor Commented:
Thanks, I'll try that.

Do you know how 'intense' this request is on the server, as the parent is used to present almost everything else on the site.

Pls e-mail me if you do.

/David
0
 
mrh30Commented:
Sorry I've not got much experience of JSPs.  We tend to develop in Perl/Javascript mainly.  I only know a few little snippets about JSPs.
0
 
larsanAuthor Commented:
OK. Thanks anyway!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now