Solved

How to retrieve a client's IP adress?

Posted on 2003-12-09
6
1,017 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
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…

776 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