• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to check if the requested server is the same server?  RSS feed

 
arthik babu
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am building a request using URL connection. Before making a connection to the server I need to check if the URL requested server is same server. If it is same then I need to call locally Instead of making URL connection.

Please help me.

Thanks in advance.

Arthik
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
arthik babu wrote:Hi,
I am building a request using URL connection. Before making a connection to the server I need to check if the URL requested server is same server. If it is same then I need to call locally Instead of making URL connection.

Please help me.

Thanks in advance.

Arthik



One way to check is with the java.net.InetAddress class. You can get the address of your local machine with the getLocalHost() method. You can also get address (or addresses) of the target host with the get[All]ByName() methods. And then see if its a match.

Henry
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!