Link to home
Start Free TrialLog in
Avatar of kerzner
kerznerFlag for United States of America

asked on

How to record an ip with the Java Web Start client?

Hi experts,

My application runs as a Java client which connects to the JBoss server on another machine. I woul d like to log the ip of the person who logs in. Usually delivered as Java Web Start.

1. Can I get his ip in the client code?
2. Maybe I should record it on the server using server's web interface though which the client is started? My only concern here is that the jnlp file is a link. Clicking on it starts the app - where is my trigger to record ip?

Thank you.
Avatar of Mick Barry
Mick Barry
Flag of Australia image

1. http://www.objects.com.au/java/qa/1360122715.html

2. Get it from request, and also get your client to collect it
the ip gathered on the client will be more accurate, think your code will need to be signed though to get it.
Avatar of kerzner

ASKER

Thank you, objects, this

InetAddress address = InetAddress.getLocalHost();
byte[] ip = address.getAddress();

gets me 127.0.0.1, I hoped to obtain the outside ip
Why not get the ip at the server end?
Avatar of kerzner

ASKER

Hi CEHJ

 Clicking on it starts the app - where is my trigger to record ip?
kerzner, how will you know which one of potentially several ip addresses was used with that approach?
>>Clicking on it starts the app - where is my trigger to record ip?

The trigger is when a uniquely-ip-addressed connection is received at the server. What better trigger can there be? ;-)
>  Clicking on it starts the app - where is my trigger to record ip?

you can get it from the request as I originally mentioned.
Not guaranteed it will be correct though
Avatar of kerzner

ASKER

thank you, CEHJ, your input is certainly valuable too - how do I give you points? How about if I add them on the next question I ask?
>>how do I give you points? How about if I add them on the next question I ask?

No - that's against site rules. The correct approach is to award them here. I'll get the q. reopened - you don't need to do anything yet

> your input is certainly valuable too

I already mentioned getting it from the request, he just repeated what I already stated.

> how do I give you points?

you don't, EE clear on comments made on closed questions. no points required (or reopening)

Avatar of kerzner

ASKER

guys, please, don't argue. You are both smart, 100 times more than I am, and you both deserve points. Somehow it will work out
Avatar of kerzner

ASKER

Ok, maybe I can ask this question - I am not sure how to I get the ip when the user clicks.

I mean, here is my jsp page. When it works, I know that it works and I can get the ip.

But after it has sent the html to the client browser, and he clicks on the jnlp link, then the server just serves this jnlp file and the applications starts. Where is the hook in my code, sort of a callback for me?
http://www.rgagnon.com/javadetails/java-0363.html

shows you how to get the address, then it's just a matter of storing it
Avatar of kerzner

ASKER

Of course, but when an html link is clicked and a jnlp file is served, no jsp page is working.

I could change this, and serve the jnlp file programmatically. Actually, it could be a good idea, because it would then allow to me serve different jnlp files from different servers.

If that makes sense, I found an answer to my question.
>>I could change this, and serve the jnlp file programmatically.

Well yes, but you don't necessarily need to serve it programatically. Simply invoke a jsp page instead of an html one
Avatar of kerzner

ASKER

I hate to be picky, but there is some misunderstanding between us.

It is already a jsp page. When it finishes working, it creates an html page, and this is what the server send to the client browser. Then the user clicks on a link in this html page, and after this no jsp is involved.

But serving jnlp page programmatically actually is even better, so I would say we are done.
>>But serving jnlp page programmatically actually is even better, so I would say we are done.

Yes, that would give you ultimate control
:-)
Netminder,

The comments posted by CEHJ simply repeated what had already been said.

Plus EE clearly states:

"Further discussion or comments related to this question may be posted to help clarify the solution, update the solution if the information is outdated, show alternate ways the solution worked for you, or other related comments. No additional expert points may be awarded to this solution."

So what exactly is going on here?? I answer the question and CEHJ gets awarded the majority of the points.

Does this mean you can go around commenting on open questions in an attempt to get them reopened???

kerzner,

exactly which comments of CEHJ did you think answered the question (How to record an ip with the Java Web Start client?) better than what I posted??
ASKER CERTIFIED SOLUTION
Avatar of Netminder
Netminder

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Well, as you can see, i was responding to the wishes of the questioner, following the site's rules against 'points passing':

>>thank you, CEHJ, your input is certainly valuable too - how do I give you points? How about if I add them on the next question I ask?
Avatar of kerzner

ASKER

sorry to have caused the disagreement, both guys are great
>>sorry to have caused the disagreement, both guys are great

Noooooo kerzner - you're not in any way responsible. Don't worry
> sorry to have caused the disagreement, both guys are great

not your fault. Just ask a new question next time if you have something else you want to ask about.
Or ask me for clarification on any answer I post :)
Avatar of kerzner

ASKER

love you both guys!