Solved

How to retrieve a client's IP adress?

Posted on 2003-12-09
6
1,015 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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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 …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

747 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