• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

IP Address of Webserver

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do I get the IP Address of Webserver from full url (as shown in the address bar) into my JSP page?
E.g.:-
URL is :- http:\\10.1.2.153\Login\Login.jsp
How Can I Get http:\\10.1.2.153 or 10.1.2.153

With Regards
Kunal
 
Ranch Hand
Posts: 395
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
you can use the following method of javax.servlet.ServletRequest interface.
public java.lang.String getRemoteAddr()
Returns the Internet Protocol (IP) address of the client that sent the request. For HTTP servlets, same as the value of the CGI variable REMOTE_ADDR.
Returns:
a String containing the IP address of the client that sent the request.
Call this method on the implicit ServletRequest object. i.e "request.getRemoteAddr()".
Cheers
NOTE: If the actual client is behind firewall or Proxy Server, you will get the IP Address of Proxy Server.
[ August 19, 2002: Message edited by: L Goundalkar ]
 
author
Posts: 621
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"kunal",
Thanks for participating here at the Ranch. However, the name you are using does not comply with our naming convention described at http://www.javaranch.com/name.jsp . Please log in with a new name, which meets these requirements.
You can change your name:
here
Thanks.
Sean
 
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by L Goundalkar:
Hi,
you can use the following method of javax.servlet.ServletRequest interface.
public java.lang.String getRemoteAddr()
Returns the Internet Protocol (IP) address of the client that sent the request. For HTTP servlets, same as the value of the CGI variable REMOTE_ADDR.
Returns:
a String containing the IP address of the client that sent the request.
Call this method on the implicit ServletRequest object. i.e "request.getRemoteAddr()".
Cheers
NOTE: If the actual client is behind firewall or Proxy Server, you will get the IP Address of Proxy Server.
[ August 19, 2002: Message edited by: L Goundalkar ]


That is not the address of the server. That is the address of the client that sent the HTTP request. If you want the name of the server which is serving the request, you use the ServletRequest.getServerName() method. Caution, this will return the server name from the URL. For example, if you use
http://123.456.789.000/myUrl
you would get back 123.456.789.000, but if you use
http://myserver.com/myUrl
you would get back myserver.com. Hope this helps.
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Here is a small program. You must know the Machine name. On Windows platform: Go to "Network Neighborhood" then "Identification" Tab.


Jamal
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic