Solved

IP & Hostname

Posted on 2004-10-14
20
327 Views
Last Modified: 2010-03-31
Hi all

I'm looking for a Java applet that :

a. does not give any output on the webpage
b. gets the users's IP, and / or hostname
c. puts this information in some hidden form field,or expose a function callable from javascript
  example :
  <script language="javascript">
   var ipnum=document.getElementById("ipget").getip()
 </script>


If this doesn't exist, can someone post the code so I can make it myself with the JDK

Note, this is very important for me so if you DO have to make the code, you'll get 1.500pts A-Grade



With kind regards



x_terminat_or_3
0
Comment
Question by:x_terminat_or_3
  • 9
  • 7
  • 4
20 Comments
 
LVL 13

Accepted Solution

by:
Webstorm earned 500 total points
ID: 12307486
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12307493
You'll need a scripting environment at the server. Do you have one?
0
 
LVL 13

Expert Comment

by:Webstorm
ID: 12307514
What you can do is create a socket to the server to transmit the session id attached to theuser, and on the server side, you read the session id and get the client IP from the socket.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12307561
You don't need to do anything special if you have a scripting environment. The server already knows your IP address, so can just output it directly into a hidden form element.

If you haven't got a scripting environment, you can use that applet above. It uses *its* own scripting environment, which is why you need the applet in that case.
0
 
LVL 2

Author Comment

by:x_terminat_or_3
ID: 12307797
I need this applet because my host doesn't allow server side scripts.  So I need to do the scripting client side.

Webstorm, I think your approach best suits my needs.

I can do it like this:

<div id="userip" style="display:none"><applet blablabla></applet></div>


and then from script,

<script language="javascript">

var ipnum=document.getElementById("userip").innerHTML;

</script>

Thanks a lot!
0
 
LVL 13

Expert Comment

by:Webstorm
ID: 12308640
:-)
0
 
LVL 2

Author Comment

by:x_terminat_or_3
ID: 12308685
actually, that didn't work, but I found how to get it to work:

<script language="javascript">
function ipdet(what)
{alert("Your IP=",what)}
</script>

<applet blablabla mayscript>
<param name="CALL" value="ipdet">
</applet>

Thanks again!
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12310827
What are you going to do with it when you get it ? ;-)
0
 
LVL 2

Author Comment

by:x_terminat_or_3
ID: 12310876
this is to include some annonymous information about the site user in a mailform
0
 
LVL 2

Author Comment

by:x_terminat_or_3
ID: 12310884
when user gets on a page, it collects the information and then submits it before showing the real page
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.

 
LVL 86

Expert Comment

by:CEHJ
ID: 12310897
>>it collects the information and then submits it

Submits it to where? I thought you were not allowed to do scripting ...
0
 
LVL 2

Author Comment

by:x_terminat_or_3
ID: 12310900
sorry


please ignore last two comments

wrong thread


The ip is checked on ip numbers in database.  If ip is in database then user is not allowed to participate on quiz.

database is updated when my mailserver receives the transcript from the quiz

0
 
LVL 2

Author Comment

by:x_terminat_or_3
ID: 12310906
only script allowed on server mailto cgi script
0
 
LVL 2

Author Comment

by:x_terminat_or_3
ID: 12310920
database is connected through <object classid="clisid.... tdc
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12310938
>>The ip is checked on ip numbers in database.  If ip is in database then user is not allowed to participate on quiz.

Submitting the ip address is a redundant procedure. The server already knows your ip address or you wouldn't be able to post a form to it
0
 
LVL 2

Author Comment

by:x_terminat_or_3
ID: 12310976
yeah that's true but it also needs the ip address when the quiz page is loaded to check if the user already has participated


page load
 ip detect
 check ip with database
 if found change page to "not alowed"
 else show quiz
 quiz submit

-----------------------
my mailserver:
 receive quizmail
 process results
 update results database
 update ipdatabase
 upload ipdatabase
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12311108
That can simply be changed to

User requests 'first' web page, server checks ip in db, redirects to 'not allowed' if present else redirects to quiz
0
 
LVL 2

Author Comment

by:x_terminat_or_3
ID: 12311379
but that's the thing, server cannot detect ip, only script allowed is mailform cgi
0
 
LVL 13

Expert Comment

by:Webstorm
ID: 12317573
>> The server already knows your ip address or you wouldn't be able to post a form to it
Not always true, for example if an user is using a proxy.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12317589
>>Not always true, for example if an user is using a proxy.

That may be the case, but if it were, having the 'real' one probably wouldn't help 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

Suggested Solutions

Title # Comments Views Activity
firstswap challenge 20 65
JUnit 4 @Before and @BeforeClass differences 3 48
JavaScript/Java - Changing an image background color 4 54
servlet example issue 6 29
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
The viewer will learn how to implement Singleton Design Pattern in Java.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

914 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

22 Experts available now in Live!

Get 1:1 Help Now