Solved

How to retrieve a client's IP adress?

Posted on 2003-12-09
6
1,016 Views
Last Modified: 2008-02-01
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
Comment
Question by:larsan
  • 3
  • 3
6 Comments
 
LVL 3

Expert Comment

by:mrh30
ID: 9903847
In JSP it's quite easy:

<%
out.print( request.getRemoteAddr() );
out.print( request.getRemoteHost() );
%>
0
 

Author Comment

by:larsan
ID: 9904298
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
 
LVL 3

Accepted Solution

by:
mrh30 earned 500 total points
ID: 9904312
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:larsan
ID: 9904332
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
 
LVL 3

Expert Comment

by:mrh30
ID: 9904360
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
 

Author Comment

by:larsan
ID: 9904410
OK. Thanks anyway!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now