| Author |
how to know ip address in JSP
|
Rekha Pande
Ranch Hand
Joined: Jan 29, 2004
Posts: 145
|
|
hi.. i have a JSP program .. in which before inserting a record i need to capture the IP address of the machine from where the record is being inserted ....can any one please help me on that..!!! Thanxs in advance for help..!!!
|
 |
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12271
|
|
The request object has the getRemoteAddr method. Look at the javax.servlet.ServletRequest JavaDocs Bill
|
 |
Rekha Pande
Ranch Hand
Joined: Jan 29, 2004
Posts: 145
|
|
if i use out.print( request.getRemoteAddr() );out.print(request.getRemoteHost() ); method...it gives me the local host ipaddress .... but it doesnot give me the machines ipaddress....how do i get the machine ipaddress of a user ... who is accessing my web pages.... please help..! thanxs..!
|
 |
Amit KumarS
Ranch Hand
Joined: Oct 10, 2003
Posts: 100
|
|
hi rekha, request.getRemoteAddr() is the method to do that as william said. you might be trying to access the JSP page from same machine on which you server is. in that case of course the IP address returned will the of the same localhost machine. try acessing the page from some other machine other then server and then see what is gives. Bye and best of luck Amit
|
****************************<br />In 24 hrs Earth rotates once on its Axis.
|
 |
Rekha Pande
Ranch Hand
Joined: Jan 29, 2004
Posts: 145
|
|
yeh i got it using out.print( java.net.Inet4Address.getLocalHost().getHostAddress() ); . thanxs for all the help...!
|
 |
 |
|
|
subject: how to know ip address in JSP
|
|
|