• Post Reply Bookmark Topic Watch Topic
  • New Topic

Contacting a site fro URL Connection...

 
vasu devan
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Can I contact a sight using URL Connection?
I know that I can give a url path with IP and port and invoke particular servlet.
Instaed if I give the domain name I am getting the following error.

Exception java.net.MalformedURLException: no protocol: www.verisign.com

Is it right to use as shown?
[B]
URL url = new URL("www.verisign.com");
URLConnection urlCon = url.openConnection();
[B]
Do suggest me how to do it.
Thanks,
Vasu
 
Junaid Bhatra
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure you can. However you have to sepcify the protocol also when you construct the URL.
For eg.,
URL url = new URL("http://www.verisign.com");
 
vasu devan
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Junaid Bhatra,
Thanks you very much, it worked.
Vasu.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!