merson
asked on
problem with getting ip address in servlet
hi,
suppose i have an html file in
http://ip1/index.htm
and is sending a request to a servlet in another server with ip2.
my problem is that how can i get ip1 from the request
within my servlet running on server ip2.
plz. note that i don't want to get the ip of client.
thanx in advance.
merson
I think you should be able to get the referrer with the getHeader(String) method of HttpServletRequest.
If u don't want the ip of the client, and you don't appear to eant the ip of the web server, then whose ip are u after?
ASKER
hi,
i want to get the ip of the server on which my html file is
uploaded.
suppose i am having my html file index.htm on server1 with ip1 and my servlet is on server2 with ip2
merson
i want to get the ip of the server on which my html file is
uploaded.
suppose i am having my html file index.htm on server1 with ip1 and my servlet is on server2 with ip2
merson
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Accept comment by rajesh_bala as answer.
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
lwinkenb
EE Cleanup Volunteer
I will leave a recommendation in the Cleanup topic area that this question is:
Accept comment by rajesh_bala as answer.
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
lwinkenb
EE Cleanup Volunteer
What you could try is to add this information to your first page, so that it's communicated to the servlet.
An example to do it via Javascript is above:
<html>
<head>
<title>Untitled</title>
</head>
<body onload="document.ip.domain
<form name="ip" action="servlet">
<input type="Hidden" name="domain" value="">
<input type="Submit" onClick="alert(document.ip
</form>
</body>
</html>
It passes the name you used to get to the server (which is not always the ip address).
Cheers,
Raffaele